ballerina-platform / ballerina-library

The Ballerina Library
https://ballerina.io/learn/api-docs/ballerina/
Apache License 2.0
137 stars 58 forks source link

Add support for the VALUE clause in the copybook module #6863

Closed MohamedSabthar closed 1 month ago

MohamedSabthar commented 1 month ago

Description: Consider the following copybook schema:

01 REC.
   03 FIELD-01                PIC XXX VALUE 'YES'.
   03 FIELD-02                PIC 9(02) VALUE 10.

When a VALUE clause is provided in the schema, the copybook module should use these values when generating ASCII string using toCopybook() API.

For the above schema the module should generate following string YES10 when no explicit values provided to the fields.

import ballerina/io;
import ballerinax/copybook;

public function main() returns error? {
    copybook:Converter converter = check new ("schema.cbl");
    map<json> inputData = {REC: {}}; // no values provided for FIELD-01 and FIELD-02
    string ascii = check converter.toCopybook(inputData);
    io:println(ascii); // YES10
}

Describe your task(s)

Related Issues (optional):

Suggested Labels (optional):

Suggested Assignees (optional):