How to precompile a COBOL-DB2 program?


Precompilation is the process through which the SQL statements used in the COBOL-DB2 program are replaced by appropriate COBOL calls. The precompilation is necessary before the actual compilation because the COBOL compiler cannot recognize the DB2 SQL statements and will throw errors due to them.

DB2 utility DSNHPC is used for the precompilation. The inputs to the precompilation JCL step are DCLGEN (in SYSLIB) for the respective tables which are used in COBOL-DB2 program and COBOL-DB2 source program (in SYSIN).

//STEP010 EXEC PGM=IKJEFT01
//SYSIN DD DSN=DIS.TEST.COBOL(PSNEW2),DISP=SHR
//SYSLIB DD DSN=DIS.TEST.DCLGEN(PSDC2), DISP=SHR
//DBRMLIB DD DSN=DIS.TEST.DBRMLIB(PSNEW2),DISP=SHR
//SYSCIN DD DSN=DIS.TEST.COBL(PSCOB2), DISP=(NEW,CATLG,DEL), SPACE=(20, (90,90))
//SYSOUT DD SYSOUT=*

Once we execute this JCL step we will receive below two main elements −

  • DBRM is received in DBRMLIB that contains all the SQL statements which were present in the program. The DBRM is further used in the BIND step to obtain a PLAN or a PACKAGE.

  • The modified COBOL source program is received in SYSCIN that has all the SQL statements replaced by COBOL calls. This modified source is further compiled and link edited.

Updated on: 11-Sep-2020

3K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements