JCL Statements – EXEC statements

 

An EXEC (or execute) statement defines the beginning of a step in a job or a procedure.                  Its purpose is to identify the program (or cataloged procedure) to be executed.

The EXEC is required of each job step.

A job can have a maximum of 255 job steps.

EXEC statement syntax

EXEC statement explanation

 

EXEC statement explanation

The EXEC statement syntax has the following parts:

  • // in columns 1 and 2
  • Step name (not mandatory, but recommended)
  • Operation EXEC
  • Positional parameters
  • Keyword parameters (not mandatory).

Step Name

A step name gives a name to a step in JCL.

The rule for step name is same as that of all names in JCL:

  • 1 to 8 bytes in length, which can be alphabetic, alphanumeric or national (#,@,$)
  • 1st byte must be alphabetic or national.
  • Must be followed by minimum 1 blank.

In above example, STEP1 is the stepname.

Please note that, the step name is an optional field, however, it is a good practice to use it with unique step names within a job.

EXEC Keyword

The literal EXEC is used to identify the start of a new step in JCL.

The operation field – EXEC is mandatory for every new step within a JCL.

Positional Parameters

There are 2 types of positional parameters: PGM= or PROC=

(a)    PGM

It specifies the program name to be executed.

In above example, ‘TESTPGM’ is the program name that will be executed.

Now, did you think from where will z/OS pick up the program load module?                                    By default, system libraries (including SYS1.LINKLIB) would be looked upon for the program module to be executed.

However, if you have a private user library where the program module is available, then you can define using the JOBLIB/STEPLIB DD statements.

If the program module is not present in the user library, then SYS1.LINKLIB library will be searched for the program module.

What will happen if the system cannot find the program module you ask it to execute?                You will get and S806 abend.

This basically means that either you need to correct your spelling of the program name, or else you need to find out the library name where the program module is residing and include that library in JOBLIB or STEPLIB DD statement.

(b)    PROC

It specifies the procedure name to be executed.

We will discuss on what a procedure is in next discussion.

However, as of now, just to understand what a procedure is – a procedure is similar to JCL but without a job card.

Here, we can COBOL is a procedure that will be executed.

The keyword PROC can be skipped, for example,

This statement will execute the procedure COBOL.

So, it is totally up to you whether to execute a procedure with or without the keyword PROC.

Keyword Parameters

Below list contains most used subset of EXEC statement keyword parameters:

Keyword Description
COND To specify rule for conditional step execution
PARM To pass parameters to the program
REGION To specify the virtual storage size for a step
TIME To specify the maximum time the step is allowed to execute

Let’s discuss these keyword parameters in detail.

(a)    COND

COND parameter is used to specify when a step is to be executed.

Z/OS provides the facility to conditionally execute job steps depending on the outcome of previous job steps.

There are 2 techniques to test the success or failure of job steps and determine whether to continue execution based on the outcome of the tests:

  • COND parameter
  • IF/THEN/ELSE/END IF statement construct.

Whenever a job is executed, every step in that job returns a status code (often termed as return code).

Depending on the return code of the JCL step, subsequent job step execution can be controlled accordingly.

It is not mandatory to use COND parameter. However, can be used as and when required.

COND parameter can be used on JOB statement and EXEC statement.

COND syntax:Cond(Source: IBM)

Cond syntax 1(Source: IBM)

Above 2 COND syntaxes can be used to bypass a step depending on the RC of the previous step.

Please note that bypassing a step because of a RC is not same as abnormally terminating/abending the step.

Bypassing a step simply means omitting a step.

If a step abends, the system will bypass all the following steps in the job.

So, for cases where steps are to be executed in ABEND scenario, COND=EVEN or COND=ONLY can be used.CONDEVEN

 

CONDONLY

 

 

 

 

 

 

 

You can make use of multiple conditions in a single COND parameter; for example;

COND=((8,LE,STEP1),(4,LT,STEP3))

Means that “this” step is to be skipped if 8 is less than or equal to actual RC by STEP1 or if 4 is less than actual RC by STEP3.

(a)    PARM

One of the ways to pass data to a program is by using PARM parameter in JCL/PROC.

If multiple data is to be passed to a program, then they should be separated by a comma ’,’ and should be enclosed in a parentheses/quotes ‘ ’

Having said that, there is a limitation on the length of data that can be passed thru PARM.

A PARM field on EXEC statement does not allow more than 100 characters, which is an architectural limit.

Note that quotes, parentheses and commas are not counted in the 100 characters.

The COBOL program will receive this data from PARM by using LINKAGE SECTION. We will see in upcoming discussion on how the data is fetched from PARM in COBOL program.PARM 1 PARM 2 PARM 3

 

(a)    REGION

We’ve already discussed this in previous discussion on JCL statements – JOB statement.

We’ll go thru it again 🙂

The REGION parameter specifies the amount of virtual storage needed by a job step.

It can be coded in JOB statement and EXEC statement as well.

If the REGION parameter is specified in JOB statement and EXEC statement, then the JOB card region parameter will override the EXEC statement region parameter.

REGION can be specified with the value equal to K (kilobytes) or M (Megabytes)

Syntax:  REGION= xx K/M

A value equal to 0K or 0M will give job all the storage available.

If the memory defined in the region parameter is not sufficient to execute the job, then the job will abend with S422/S822.

(b)    TIME

This has also been discussed in previous discussion on JCL statements – JOB statement.

We’ll go thru it again 🙂

time1 Time is sinking

 

 

 

 

 

 

 

Most batch systems automatically cancel a program caught in an endless loop after a reasonable time has passed.

The data for setting the timer must come from somewhere.

This task is done by using the TIME parameter.

TIME parameter signifies the maximum time that the JOB or STEP can take to run.

It can be coded in both JOB & EXEC statements.

If it is coded in both JOB and EXEC statements, the smaller among them will be applicable.

Syntax: TIME=NOLIMIT         -> JOB can utilize the processor for any amount of time.

                TIME = MAXIMUM    -> JOB or STEP can be used for maximum amount of                                                                        time i.e. 357,912 minutes.

                TIME = (minutes, seconds) 

 Please note that TIME=1440 is equivalent to coding TIME=NOLIMIT. Thus, 1440 is the only numerical value that is not to be interpreted directly.

When there is a time out, the abend code is S322.

 

This was all about the EXEC statements in a JCL.

DYK