Coding Simple JOB Example


JCL is used to run batch jobs on IBM Mainframe systems. A simple JCL consists of a JOB statement, EXEC statement, and DD statements. Below are the basic steps to code and run a simple JCL:

  • Understand the Project Requirements
  • Collect Project specific information
  • Create a new PDS or use existing PDS to create a JCL member.
  • Code the JCL in the member.
  • Submit the JCL to see the expected result.

Understand the Project Requirements


Before going to code the JCL, we need to understand the requirement and collect the information. Those are -

  • Sorting, merging, copying files.
  • Running COBOL or PL/I programs.
  • Generating reports.
  • Transferring files (FTP, SFTP) etc,.

Collect Project specific information


Different projects has the different installations and the parameter values might change based on the installation setup. We need to get the project specific information from the existing team members in the team. Those are -

  • JOB statement prameters information. For example - CLASS=A for short run jobs and CLASS=M for long running jobs
  • Files starting qualifier for PROD and different test environments. For example - MTHTEST.* is for development and MTHPROD.* for production.
  • Personal libraries starting with your TSO id allowed or not. For example - MATEPK.*
  • Libraries names for PROD and test environments. For example - MTHPROD.COBOL.LOADLIB, MTHPROD.PARMLIB, etc,.
  • Many more..

Create a new PDS or use existing PDS to create a JCL member


Go through the create new PDS  topic if you are creating new PDS and then follow creating new member  topic in the PDS process to create a new JCL member. Make sure that the new PDS or existing PDS name ends with JCLLIB or JOBLIB to differ it from other PDS to easily identify the JCL library. For example - MATEPK.DEV.JCLLIB or MATEPK.DEV.JOBLIB.

Code the JCL in the member


Open the PDS member in edit mode and code the JCL accoding to the coding sheet. Write the JCL code in it and save the member. For example - MATEPK.DEV.JOBLIB(TESTJCL) is the new JCL member created.

Scenario - Create a new JCL for creating a new file.

PDS and Member name - MATEPK.DEV.JOBLIB(TESTJCL)

----+----1----+----2----+----3----+---4----+---5---+
//MATEPKI  JOB (123),'MTH',CLASS=A,MSGCLASS=A,
//             MSGLEVEL=(1,1),NOTIFY=&SYSUID 
//*
//STEP01   EXEC PGM=IEFBR14
//DD1      DD DSN=MATEPK.IEFBR14.PSFILE,
//            DISP=(NEW,CATLG,DELETE),
//            SPACE=(TRK,(3,2),RLSE),
//            UNIT=SYSDA,VOLUME=SER=DEVHD4,
//            DCB=(DSORG=PS,RECFM=FB,LRECL=80,BLKSIZE=800)

Explaining Example -

  • DISP=(NEW,CATLG,DELETE) - specifies creates the new file.
  • DCB=(DSORG=PS,RECFM=FB,LRECL=80,BLKSIZE=800) - Specifies the PS file with record length 80 and block size 800.
  • IEF142I MATEPKI STEP01 - STEP WAS EXECUTED - COND CODE 0000 - Specifies the STEP01 completed successfully.
  • MATEPK.IEFBR14.PSFILE  CATALOGED - Specifies the MATEPK.IEFBR14.PSFILE file successfully created and cataloged.

Submit the JCL to see the expected result


Once the JCL is ready, submit the JCL using "SUBMIT" command at the TSO to see the output.

To see the output, go to Spool (SDSF -> ST) and verify the status in the JESYSMSG DDname of the corresponding job.

Allocate PS Status