JCL EXEC Statement

EXEC statement
EXEC statement with Parameters
EXEC stands for Execution. 
  • We can create Steps in JCL using ‘EXEC’ statement.
  • EXEC statement includes the program, utilities, and procedures where we can use this for execution of that particular step.

Note: JCL allows Maximum 255 steps. This means maximum 255 ‘EXEC’ statements are allowed in a JCL.

The Syntax of the EXEC statement

//[stepname]    EXEC      [{parameter1,parameter2,…}]

Furthermore, stepname is optional but also it is always advisable to provide a step name until you have a special requirement to skip the step name.

Most used EXEC Format/Example 1

//STEP10   EXEC PGM=IDCAMS

This Format/Example 1 is the simplest form of EXEC statement. This EXEC statement contains a step with a name ‘STEP10’ and we can use this step to execute a utility program ‘IDCAMS’.
Here, you can use any step name and utility based on your requirement and this example is just to show the format.

When to use –

If we have a simple requirement to execute a program without defining any parameter at step level, then we can use this format.

Most used EXEC Format/Example 2

//STEP01 EXEC PGM=IKJEFT01, 
//       DYNAMNBR=20,REGION=4096K
When to use

This Format/Example 2 is one of the examples when we are required to execute a program and we are also required to set some parameters.

For Example – In this case, you require to provide DYNAMNBR and REGION parameter at step level.

Most used EXEC Format/Example 3

//CICSCOB EXEC CICSCOBC, 
//        COPYLIB=MATEKS.COPYLIB, <=COPYBOOKLIBRARY
//        SRCLIB=MATEKS.CICS.SRCLIB, <= SOURCE LIBRARY 
//        MEMBER=SEND01 <= SOURCE MEMBER
This Format/Example 3 is used to run a CICSCOBC.

This step uses a particular
 – Copybook library
 – Source Library
 – a member
which will be used for only this step.

When to use

If we have a requirement where you need to include your copybook library or source library which is different for the library defined at the job level.

Then we can use this format-

The step name, procedure name, copybook, source library, member are used for a specific purpose. We can give your own step name, procedure name, a location of copybook library, a location of source library or member etc. We have also skipped those parameters which are not required for our project.

For Example – You can remove the copybook library, source library or member. 

Most used EXEC Format/Example 4

//STEP04   EXEC PROC=CATLPROC

This Format/Example 4 is the simplest form of EXEC statement. This EXEC statement contains a step with a name ‘STEP04’ and this step is used to execute a cataloged procedure ‘CATPROC’ Here, you can use any step name and cataloged procedure of your choice based on your requirement and this example is just to show the format.

When to use –

If we have a simple requirement to call a catalog procedure without defining any parameter at step level, then you can use this format.

Less used EXEC Format/Example 5

//CL EXEC IGYWCL 
//COBOL.SYSIN DD DSN=MATEKS.COBOL.SRCLIB(MAINPGM),DISP=SHR 
//COBOL.SYSLIB DD DSN=MATEKS.COPYLIB,DISP=SHR 
//LKED.SYSLMOD DD DSN=MATEKS.LOADLIB(MAINPGM),DISP=OLD 
//LKED.SYSIN DD DSN=MATEKS.LOADLIB(SUBPGM),DISP=OLD
This Format/Example 5 is used to run a compiler utility.

This step uses a particular – – – – Copybook library
– Source Library
– load libraries
– for the main program and the subprogram.

When to use-

When we have a specific requirement only. Suppose, you have the main program and a called program then you can use this.

JCL Interview Question and Answers

1. What are the procs allowed inside JCL

a. Cataloged
b. In-stream
c. a & b
d. Only a

a. Cataloged

3. Can we define an instream proc after a EXEC Statement

Yes / No

Tutorials for all brains!