DB2 Precompilation Process
DB2 Precompilation Process Example
Practical Example -
Scenario - Below example describes how the COBOL + DB2 program precompiled using JCL.
Input - EMPLOYEE_DETAILS table
COBOL + DB2 Program to retrieve employee with id 5.
----+----1----+----2----+----3----+----4----+----5----+
IDENTIFICATION DIVISION.
PROGRAM-ID. SELECT1.
ENVIRONMENT DIVISION.
DATA DIVISION.
WORKING-STORAGE SECTION.
EXEC SQL
INCLUDE SQLCA
END-EXEC.
EXEC SQL
INCLUDE EMPLDET
END-EXEC.
01 WS-EMPID PIC S9(9) USAGE COMP.
PROCEDURE DIVISION.
MOVE 5 TO WS-EMPID.
EXEC SQL
SELECT EMP_ID,
EMP_NAME,
DESIGNATION,
MANAGER_ID,
DATE_OF_HIRE,
SALARY,
DEPT_ID
INTO :EMP-ID,
:EMP-NAME,
:DESIGNATION,
:MANAGER-ID,
:DATE-OF-HIRE,
:SALARY,
:DEPT-ID
FROM EMPLOYEE_DETAILS
WHERE EMP_ID = :WS-EMPID
END-EXEC.
IF SQLCODE = 0
DISPLAY EMP-ID,"|",EMP-NAME,"|",DESIGNATION,"|",
MANAGER-ID,"|",DATE-OF-HIRE,"|",SALARY,"|",DEPT-ID
ELSE
IF SQLCODE = 100
DISPLAY "EMPLOYEE DETAILS NOT FOUND"
ELSE
DISPLAY "DB2 ERROR"
END-IF
END-IF.
STOP RUN.
Precompile Sample JCL Code -
----+----1----+----2----+----3----+----4----+----5----+
//MATEGJP JOB MSGLEVEL=(1,1),NOTIFY=&SYSUID
//*********************************************************
//* COBOL + DB2 PRECOMPILE AND LINKEDIT *
//*********************************************************
//PCSTEP EXEC PGM=DSNHPC,
// PARM='HOST(IBMCOB),XREF,SOURCE,FLAG(I),APOST'
//STEPLIB DD DISP=SHR,DSN=DSNA10.DBAG.SDSNEXIT
// DD DISP=SHR,DSN=DSNA10.SDSNLOAD
//SYSCIN DD DSN=&&DSNHOUT,DISP=(MOD,PASS),UNIT=SYSDA,
// SPACE=(800,(500,500))
//SYSIN DD DSN=MATEGJ.COBDB2.SRCLIB(SELECT1),DISP=SHR
//SYSLIB DD DSN=MATEGJ.COBDB2.DCLGEN,DISP=SHR
// DD DSN=MATEGJ.COBDB2.COPYLIB,DISP=SHR
//DBRMLIB DD DSN=MATEGJ.COBDB2.DBRMLIB(SELECT1),DISP=SHR
//SYSPRINT DD SYSOUT=*
//SYSTERM DD SYSOUT=*
//SYSUDUMP DD SYSOUT=*
//SYSUT1 DD SPACE=(800,(500,500),,,ROUND),UNIT=SYSDA
//SYSUT2 DD SPACE=(800,(500,500),,,ROUND),UNIT=SYSDA
//**********************************************************
//* Compile the COBOL program if the precompile *
//* return code is 4 or less. *
//**********************************************************
//COB EXEC PGM=IGYCRCTL,
// PARM=('SIZE(4000K),BUFSIZE(32760),
LIST,LIB,MAP,OBJECT',
// 'DATA(31),XREF,RENT'),
// COND=(4,LT,PCSTEP)
//STEPLIB DD DSNAME=IGY420.SIGYCOMP,DISP=SHR
//SYSPRINT DD SYSOUT=*
//SYSTERM DD SYSOUT=*
//SYSLIN DD DSN=&&LOADSET,DISP=(MOD,PASS),UNIT=SYSDA,
// SPACE=(800,(500,500))
//SYSLIB DD DSN=MATEGJ.COBDB2.COPYLIB,DISP=SHR
//SYSIN DD DSN=&&DSNHOUT,DISP=(OLD,DELETE)
//SYSUT1 DD SPACE=(800,(500,500),,,ROUND),UNIT=SYSDA
//SYSUT2 DD SPACE=(800,(500,500),,,ROUND),UNIT=SYSDA
//SYSUT3 DD SPACE=(800,(500,500),,,ROUND),UNIT=SYSDA
//SYSUT4 DD SPACE=(800,(500,500),,,ROUND),UNIT=SYSDA
//SYSUT5 DD SPACE=(800,(500,500),,,ROUND),UNIT=SYSDA
//SYSUT6 DD SPACE=(800,(500,500),,,ROUND),UNIT=SYSDA
//SYSUT7 DD SPACE=(800,(500,500),,,ROUND),UNIT=SYSDA
//***************************************************
//* Linkedit if the precompile and compile *
//* return codes are 4 or less. *
//***************************************************
//LKED EXEC PGM=IEWL,PARM='MAP,XREF',
// COND=((4,LT,PCSTEP),(4,LT,COB))
//SYSLIB DD DISP=SHR,DSN=CEE.SCEELKED
// DD DISP=SHR,DSN=DSNA10.SDSNLOAD
// DD DISP=SHR,DSN=ISP.SISPLOAD
// DD DISP=SHR,DSN=GDDM.SADMMOD
// DD DISP=SHR,DSN=MATEGJ.COBDB2.LOADLIB
//SYSLIN DD DSN=&&LOADSET,DISP=(OLD,DELETE)
// DD DDNAME=SYSIN
//SYSLMOD DD DSN=MATEGJ.COBDB2.LOADLIB(SELECT1),DISP=SHR
//SYSPRINT DD SYSOUT=*
//SYSUT1 DD SPACE=(1024,(50,50)),UNIT=SYSDA
//SYSIN DD DUMMY
JOB Result - MAXCC
JOB Result - Precompile Step
JOB Result - Precompile Step Final Report