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.

EXEC SQL
     INCLUDE SQLCA
END-EXEC

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:

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.   

Link-Edit is a process that accepts the Object Modules and references to the other modules(or to external references) and combines them together to form a single Load module. This process also stores this load module in a PDS and loads it into Storage so that it can be accessed to execute that program.

While executing the program Load Module & the Plan details needs to be provided as shown in the below example.

COBOL DB2 program will be executed thru a terminal interface utility IKJEFT01.

Ex:

//STEP1 EXEC PGM=IKJEFT01,REGION=0M
//SYSPRINT DD SYSOUT=*
//STEPLIB  DD DSN=MGR.TEST.LOADLIB,DISP=SHR 
//SYSTSPRT DD SYSOUT=*
//SYSOUT DD SYSOUT=*
//SYSABOUT DD SYSOUT=*
//SYSDBOUT DD SYSOUT=*
//SYSTSIN DD *
DSN SYSTEM(DT10)
RUN PROGRAM (MGLIST1) PLAN(PLAN1) PARMS('xxxx')
END
/
2 Comments

Leave a Reply to admin Cancel reply

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

Close Bitnami banner