EXEC Statement


Before proceding with EXEC statement, refer the JCL Coding sheet topic.

Each step in JCL executes a program or a procedure (have one or more steps) using the EXEC statement. EXEC statement treats as the beginning of the step and required for each step. A JCL can have a maximum of 255 steps.

The main purpose of the EXEC statement is to provide the necessary information to the operating system to execute the job step, including the name of the program or utility to be run, any input or output datasets, and any other parameters or options required for the step.

Syntax -

//[stepname]  EXEC  parameters [comments]

Notes -

  • EXEC keyword should start at the 12th column and should end at the 15th column.
  • A step ends with the null statement ('//') or at the beginning of another step.

Stepname -


Step name is used to identify the step uniquely in the JCL. Step name is optional; if coded, step name should be unique in the entire job.

Rules -

  • The stepname should start from the 3rd column.
  • Stepname can be 1-8 characters.
  • Stepname is a combination of alphanumeric and special characters (@,#, and $).
  • One blank/space should follow the stepname before EXEC.

EXEC keyword -


  • EXEC is the keyword used to code the EXEC step in JCL.
  • The job entry system (JES) identifies the step using the EXEC keyword.
  • A job can have 255 steps.

Parameters -


EXEC statement parameters are treated as local to the step and only apply to the specific step in the job. If any parameter is coded at the step and JOB level, the step level parameter has the highest priority.

EXEC statement parameters are divided into three types -

  • Positional parameters.
  • Keyword parameters.
  • Symbolic parameters.

Positional parameter (positional-parameters) -


PGM The PGM parameter is used to specify the program that needs to be run by the system. The program name specified with PGM should be a clean compiled program ready to execute.
Syntax - PGM=program-name
program-name specifies the application program name.
Example - Executing a program.
//MTHEXMP1 JOB (META007),'PAWAN Y', MSGLEVEL=(1,1)
//STEP1    EXEC PGM=SAMPLE
//STEPLIB  DD   DSN=MTH.MY.LOADLIB,DISP=SHR
PROC PROC parameter is used to specify the procedure that needs to be run by the system. The procedure can be an instream or cataloged.
Syntax - EXEC PROC=procedure-name
procedure-name specifies the procedure name to be executed.
Example - Calls procedure named MTHPROC.
//STEP01  EXEC MTHPROC

Positional parameters are optional, and if coded, they should start immediately after the EXEC statement. Positional parameters can start in any column.

Keyword parameters (keyword-parameters) -


Below keyword parameters that are part of JOB statement and also applicable to EXEC statement -

Keyword ParameterPurpose
ACCT Specifies step accounting information.
ADDRSPC Specifies the type of the storage required for the step.
COND Specifies the return code tests used to determine the specific step execution.
MEMLIMIT Specifies the limit on total number of usable virtual pages above the bar.
RD Specifies the user authority for automatic restart.
REGION Specifies the Maximum amount of space required by the step.
TIME Specifies the Maximum amount of processor time the step can use.

Below keyword parameters that are not part of JOB statement and only applicable to EXEC statement -

Keyword ParameterPurpose
DYNAMNBR Holds the number of dataset allocations for reuse.
PARM Used to pass the input data to the program.

Comment -


Comment used to make a note of the current statement. The comment field follows the parameter field and should have a blank after the parameter field.

Examples -


Scenario1 - EXEC statement with step name.

//STEP1  EXEC PGM=TESTPROG,PARM='MTH'

The EXEC statement named STEP1 invokes a program called TESTPROG and passes the value in the PARM parameter.

Scenario2 - EXEC statement without step name

//      EXEC PGM=TESTPROG,REGION=2K

This EXEC statement without a stepname invokes a program TESTPROG. It specifies the maximum space for the execution of the step.

Learn More?