Cobol DB2 Program execution and Coding requirements

Unlike a normal COBOL program COBOL DB2 program has some special requirements to be considered while coding and execution. For ex: In the coding it is required to include the SQLCA and the program needs to be executed via Terminal monitor Program etc.

COBOL DB2 Coding Part:

1. Do the coding as per the requirement, as it is the Cobol-DB2 program take a look at the below considerations

i. Include the SQLCA (SQL Communication area). SQLCA is the mandatory in most of the cases. It contains the statistics of the SQL that got executed. Include it in the working storage section.

ii) Include the logic to handle the SQLCODE after the SQL statements, this is not mandatory, but it will be mostly used to handle the Successful (SQLCODE 0), Row not found in tables (SQL CODE 100) and other error conditions (sql code other than 0 & 100)

iii) Use the DCLGEN variables for the DB2 tables that have been used in that program. It’s not mandatory to use DCLGEN; instead we can also use the working storage variables. But using DCLGEN gives the consistency between the Tables variables and Host variables.

Compilation Process:

We have already discussed this in our previous topic. I will brief those over here:

For a normal COBOL program only compiling the code will be enough to create a load module. But in case of COBOL-DB2 program, the compiler does not understand the SQL statements. As a result compiler will throw inconsistent results. So Pre compilation process got introduced.

So in COBOL DB2 compilation 4 parts will be there.

1- Pre-compilation 2- COBOL module compiles 3- Bind 4- Link EDIT


Pre compilation is the first process where it does a simple thing; it looks for all the SQL statements that are present in the COBOL DB2 source and it takes out all these statements and creates database request Module (DBRM).

And it replaces the SQL Statements in the source with compiler understandable CALL statements.

Also it does various things like basic Syntax checking etc.

Bind Process:

Bind process is equivalent to the COBOL code compilation, where as it process the SQL statements. The primary input to this is the DBRM, which got generated as part of the pre-compilation.

Link Edit. Both the object modules that got generated in the BIND (Db2 part) and Compilation( cobol Source) will be combined together in this phase.

Execution Part:

COBOL DB2 program will be executed thu a terminal interface utility IKJEFT01


Leave a Reply

Your email address will not be published. Required fields are marked *