Let's understand Mainframe
Home Tutorials Interview Q&A Quiz Mainframe Memes Contact us About us

Module 13: Compile, Link and Execute


Example of Running COBOL program using JCL

Assumption:-

  • Cobol program is stored in ENDV.TEST.SRCLIB(MFPROG1)
  • Load library has already created with name : ENDV.TEST.LOADLIB

COBOL Program:-

Location: ENDV.TEST.SRCLIB(MFPROG1)

000100 IDENTIFICATION DIVISION. 000200 PROGRAM-ID. MFPROG1. 000300 PROCEDURE DIVISION. 000400 MAIN-PARA. 000500 DISPLAY 'HELLO WORLD' 000600 STOP RUN.

Above cobol program will display string ‘HELLO WORLD’ in SYSOUT when executed and name of program is given is MFPROG1

JCL to Compile and Link-edit COBOL Program:-

//COMPLNK JOB (1234567),'MFB',CLASS=L,MSGCLASS=X, // MSGLEVEL=(1,1),NOTIFY=TRAIN01 //*------------------------------------------------------- //* DECLARATION OF VARIABLES //*------------------------------------------------------- // SET WSPC=500 // SET MEM=MFPROG1 // SET SRC=ENDV.TEST.SRCLIB // SET LOAD=ENDV.TEST.LOADLIB //*------------------------------------------------------- //*COMPILE STEP //*------------------------------------------------------- //COBSTEP EXEC PGM=IGYCRCTL,REGION=2048K //SYSPRINT DD SYSOUT=A //SYSLIN DD DSN=&LOADSET,DISP=(MOD,PASS),UNIT=SYSDA, // SPACE=(800,(&WSPC,&WSPC)) //SYSIN DD DSN=&SRC(&MEM),DISP=SHR //SYSUT1 DD SPACE=(800,(&WSPC,&WSPC),,,ROUND),UNIT=SYSDA //SYSUT2 DD SPACE=(800,(&WSPC,&WSPC),,,ROUND),UNIT=SYSDA //SYSUT3 DD SPACE=(800,(&WSPC,&WSPC),,,ROUND),UNIT=SYSDA //SYSUT4 DD SPACE=(800,(&WSPC,&WSPC),,,ROUND),UNIT=SYSDA //SYSUT5 DD SPACE=(800,(&WSPC,&WSPC),,,ROUND),UNIT=SYSDA //SYSUT6 DD SPACE=(800,(&WSPC,&WSPC),,,ROUND),UNIT=SYSDA //SYSUT7 DD SPACE=(800,(&WSPC,&WSPC),,,ROUND),UNIT=SYSDA //*------------------------------------------------------- //*LINK EDIT STEP //*------------------------------------------------- //LKEDSTP EXEC PGM=IEWL //SYSLIB DD DSN=CEE.SCEELKED,DISP=SHR //SYSLIN DD DSN=&&LOADSET,DISP=(OLD,DELETE) // DD DDNAME=SYSIN //SYSLMOD DD DSN=&LOAD(&MEM), // DISP=SHR //SYSPRINT DD SYSOUT=A //SYSUT1 DD SPACE=(1024,(50,50)),UNIT=SYSDA

Above code snippet has two important EXEC steps:-

  • COBSTEP, which will convert COBOL source program MFPROG1 residing at ENDV.TEST.SRCLIB to object module and will store it at temp dataset &&LOADSET
  • LKEDSTP, which will convert object code contained in temp dataset &&LOADSET to load module and will be stored at ENDV.TEST.LOADLIB

Run JCL:-

//COMPLNK JOB (1234567),'MFB',CLASS=L,MSGCLASS=X, // MSGLEVEL=(1,1),NOTIFY=TRAIN01 //STEP01 EXEC PGM=MFPROG1 //STEPLIB DD DSN=ENDV.TEST.LOADLIB,DISP=SHR //SYSOUT DD SYSOUT=A //

Explanation:

Above job will execute program MFPROG1 whose load module residing at ENDV.TEST.LOADLIB and on successful completion of job, you will be able to see string ‘HELLO WORLD’ displayed in SYSOUT






© copyright mainframebug.com
Privacy Policy