Automated conversion of native COBOL programs into EGL programs with a single click. The system accepts a COBOL source file as input and automatically generates a functionally equivalent EGL file using a Java-based conversion tool, while adopting EGL’s modern structure and syntax.
The COBOL-to-EGL conversion process is as follows:
-
Automated COBOL-to-EGL Conversion: Develop a Java-based conversion tool that transforms COBOL programs into equivalent EGL files while maintaining functional accuracy.
-
ANTLR-Based COBOL Parsing:
-
Command-Line Batch Execution: Enables a command-line execution using a batch script to make the conversion process efficient and user-friendly.
-
Input and Output Handling: Accept COBOL source files as input and generate structured EGL output files automatically.
-
Logging and Debugging: Creates detailed log files for every conversion process, capturing execution status, warnings, and errors for debugging and analysis.
-
Modular and Scalable Design: Ensure to design the system with a modular structure to support future enhancements and enable the processing of multiple COBOL files efficiently.

Specifications
-
The ANTLR-generated parser supports standard COBOL syntax based on the defined grammar rules.
-
The input COBOL program must be syntactically valid. Invalid COBOL syntax may result in parsing errors during conversion.
-
The conversion process is designed for the TANDEM COBOL format. Both TANDEM COBOL and IBM z/OS COBOL follow COBOL 85 standards with minor deviations.
-
Before executing native COBOL programs on Windows, update comment lines from * format to *>, as TANDEM supports only the *> comment format.
-
Sign Function Limitation: The ANTLR parser recognizes the SIGN keyword in the Working-Storage Section. However, when used as a function in the Procedure Division, it may produce a parser error.
-
Temporary Workaround: Replace FUNCTION SIGN with FUNCTION SIGN1 before code generation. After EGL code generation, revert SIGN1 back to SIGN before execution.
Pre-Requisites
Steps for Conversion and Execution
Input and Output flow

-
Input File (COBOL File): The COBOL source program provided as input for the conversion process.
-
Conversion Process: The Java-based conversion tool uses ANTLR to parse the COBOL source code and generate the corresponding EGL file.
-
Output File (EGL File): The converted EGL file is generated and stored in the designated output directory.
-
Log File (.log File): A log file with the same name as the input file is created to capture conversion details, warnings, and error messages for troubleshooting and analysis.
Batch Script Execution:
1. The COBOL source code is converted to EGL and compiled into a runnable JAR file, and a batch script is created to run it from the command prompt.

2. Configure the JAR file path in the batch script as required.
3. After setting the JAR path, open the command prompt in the same directory and execute the batch script using the following syntax:
<batch script.bat> -sourcefile <CBL file location> -gendirectory <output EGL file location till package name> -format TANDEM -package <package name>

-
Upon successful execution, the generation details are displayed in the console.

-
A Sample native COBOL program.

-
The converted EGL program is below. The EGL program is further generated into a corresponding COBOL program from the IBD workspace for execution in the mainframe environment.

-
Additionally, the EGL log file is also created in the same output location as the EGL file.

-
The output of the generated EGL program.

Limitations
Working storage section:
Procedure Division statements:
-
The ALSO keyword is not implemented in the Evaluate statement.
Example:
EVALUATE MARKS ALSO TRUE
WHEN 30 THRU 50 ALSO GRADE = "D" DISPLAY "JUST PASS"
END-EVALUATE.
-
WHEN OTHER should be added in a COBOL program as a mandatory, otherwise the parser will throw an error and generation will be interrupted.
-
Multiple variables in the GO TO statement are not supported in EGL. GO TO PARA-1 PARA-2 PARA-3 DEPENDING ON WS-P.
Note: Go To supports only one label. Multiple labels are not supported in EGL.
For more information, refer to https://help.blueproddoc.com/ibd/10.0.0/com.ibm.egl.lr.doc/topics/regl_core_go_to.html?hl=goto%2Cegl
-
SPACES are required around arithmetic operators to avoid ambiguity. Ambiguous expressions can result in unpredictable output.
Example:
COMPUTE X = (X+Y)*(X-Y)
X+Y, while not strictly correct, may get accepted
X-Y will be treated as a single variable X-Y, and not X-Y, and will result in an error if a minus was intended.
Expected COBOL Syntax:
COMPUTE X = (X + Y)*(X - Y)* Y** (-Z)
-
The ROUNDED keyword is ignored.
Example:
COMPUTE X ROUNDED = (X+Y)*(X - Y)* Y** (-Z)
-
DISPLAY statement with the keywords as below is ignored.
AT, UPON, WITH [NO] ADVANCING
-
Call Statement: JCL is the main program, and COBOL is a subprogram in which JCL passing input to the subprogram is not implemented.
-
The GIVING phrase is not implemented as IBM COBOL does not support this function.
-
CALL BY VALUE supporting datatypes: COMP, COMP-5, BINARY, POINTER, INDEX, FLOAT, DOUBLE, NUMERIC LITERALS.
-
Onsize Error : MULTIPLY WS-NUM1 BY WS-NUM3 GIVING WS-RESULT
ON SIZE ERROR
DISPLAY "ERROR WITH RESULT SIZE"
NOT ON SIZE ERROR
DISPLAY "RESULT VALUE IS: " WS-RESULT.
Native COBOL: WS-NUM1 PIC 9(3). WS-RESULT PIC 9(1).
EGL Data type:
WSNUM1 smallint;
WSRESULT smallint;
Generated COBOL:
WSNUM1 PIC S9(4) COMP-4.
WSRESULT PIC S9(4) COMP-4.
In EGL, we don’t have a length for INT variables like COBOL 9(2) / 9(5).
As WS-RESULT is s9(4) comp-4, it can accommodate only 4 digits.
Hence, the generated COBOL pgm does not throw “On Size Error” statements. If more than 4 digits, then the corresponding “OnSizeError” statements are invoked.
-
Post-conversion, Leading Zeros/Spaces are being suppressed: VAR1 PIC 9(3) VALUE 12.
DISPLAY VAR1 will display in the console as 012.
In the generated COBOL, the output is 12.
In EGL, smallint converted to S9(4) COMP-4. When displaying any smallint, int, numeric, or decimal variable, the generated COBOL code removes or truncates preceding zeros.
-
Intrinsic Functions:
-
Seconds-from-formatted-time: This function implementation is performed in the EGL; however, as a native COBOL program, it throws a compilation error when the first argument is passed.
-
The functions “CHAR, COMBINED-DATETIME, HEX-TO-CHAR” give incorrect results in the native COBOL program.
-
In COBOL File operations, opening a file in an extended mode (writing to existing files) is not supported in EGL(Generated COBOL).
-
Dynamic Array (DEPENDING ON CLAUSE):
Note 1: We can not initialize dynamic arrays in structure records in EGL.
Note 2: If we have initialized the static array in the structure record in EGL, we can't resize it in the main function
Example:
EGL Record:
Record
$EmployeeRecord type basicRecord
5 $EmpId int ;
5 $EmpName char(30) ;
5 $NumDependents smallint = 0;
5 rec$DependentInfo $DependentInfo[10] ;
end
CASE 1:- Can not initialize the dynamic array inside structured records:-
5 rec$DependentInfo $DependentInfo[];

OR 5 rec$DependentInfo $DependentInfo[]{maxSize=10};

For reference:-
https://help.blueproddoc.com/ibd/10.0.0/com.ibm.egl.lr.doc/topics/regl_core_structured_rec.html

CASE 2:- Can not resize the array "rec$EmployeeRecord.rec$DependentInfo.resize(5);"

Author
Sasipriya B
Developer – RBD
⚡️IBM z17 is here! Powered by the new IBM Telum II processor, IBM z17 makes more possible, empowering organizations to drive innovation and do more with their data while processing sixty percent more transactions per day than IBM z16. See what sets IBM z17 apart here.
