Master Mainframe Technologies - COBOL, JCL, DB2, VSAM, CICS & More
ABEND Codes SQLCODEs File Status Interview Prep Contact
🖥 JCL

JCL EXEC Statement

Beginner 🕑 18 min read 👁 1 views

EXEC Statement Overview

The EXEC statement identifies the program or procedure to be executed in a job step.

EXEC Statement Formats

  1. PGM= - Execute a program
  2. PROC= - Execute a cataloged procedure
  3. Procedure name without PROC=

Common EXEC Parameters

ParameterDescription
PGMProgram name to execute
PROCProcedure name to execute
PARMParameters passed to program
CONDCondition code testing
TIMEStep time limit
REGIONStep memory allocation
ACCTStep accounting information

COND Parameter

Controls step execution based on return codes:

COND=(code,operator)
COND=(code,operator,stepname)
COND=EVEN - Execute even if previous step abends
COND=ONLY - Execute only if previous step abends

Operators for COND

  • GT - Greater than
  • GE - Greater than or equal
  • LT - Less than
  • LE - Less than or equal
  • EQ - Equal
  • NE - Not equal

PARM Parameter

Pass parameters to programs:

PARM="parameter string"
PARM=(parm1,parm2)

Code Example

//STEP01   EXEC PGM=IEFBR14
//*
//STEP02   EXEC PGM=MYCOBOL,
//             PARM="PARAM1,PARAM2",
//             TIME=(5,30),
//             REGION=64M
//*
//STEP03   EXEC PGM=SORTPGM,
//             COND=(4,LT,STEP02)
//*
//* COND EXAMPLES
//STEP04   EXEC PGM=PROG1,COND=(0,NE)
//* Skip if any previous RC not equal to 0
//*
//STEP05   EXEC PGM=PROG2,COND=((4,LT),(8,EQ,STEP02))
//* Skip if RC < 4 OR STEP02 RC = 8
//*
//STEP06   EXEC PGM=CLEANUP,COND=EVEN
//* Execute even if previous step abended
//*
//STEP07   EXEC PGM=ERRRPT,COND=ONLY
//* Execute only if previous step abended
//*
//* EXECUTING A PROCEDURE
//STEP08   EXEC PROC=COBCLG
//         or
//STEP08   EXEC COBCLG
//*
//* PROCEDURE WITH OVERRIDE
//STEP09   EXEC MYPROC,PARM.STEP1="OVERRIDE"