JCL - Procedures or PROC
Some programs and tasks require a larger amount of JCL than a user can easily enter. JCL for these functions can be kept in procedure libraries.
A procedure library member contains only part of the JCL for a given task-usually the fixed, unchanging part of JCL. The user of the procedure supplies the variable part of the JCL for a specific job. In other words, a JCL procedure is like a macro.
For jobs that you run frequently or types of jobs that use the same job control, prepare sets of job control statements, called procedures.
In other words, Set of Job control statements that are frequently used are defined separately as a procedure and it can be invoked as many times as we need from the job. The use of procedures helps in minimizing duplication of code and probability of error.
Statements which are not Allowed in a Procedure
You can place most statements in a procedure, but there are a few exceptions. Some of these exceptions are:
The JOB statement and JES2/JES3 Control statements.
The JOBCAT and JOBLIB statement.
An instream procedure (an internal PROC/PEND pair)
SYSIN DD *, DATA statements
There are two types of procedures available in JCL,
When the procedure is coded within the same JCL member, it is called an Instream Procedure.
An in-stream procedure must begin with a PROC statement, end with a PEND statement, and include only the following other JCL statements: CNTL, comment, DD, ENDCNTL, EXEC, IF/THEN/ELSE/ENDIF, INCLUDE, OUTPUT JCL, and SET.
You must observe the following restrictions regarding in-stream procedures:
- Do not place any JCL statements (other than the ones listed here) or any JES2 or JES3 control statements in the procedure.
- Do not define one in-stream procedure within another, that is, do not use nested in-stream procedures. Refer to Nested procedures for information on methods for nesting procedures.
- Do not use an in-stream procedure if the procedure will be run as a started job under the MASTER subsystem, that is, includes a JOB statement and is started via a START command such as S membername,SUB=MSTR.
When the procedure is separated out from the JCL and coded in a different data store, it is called a Cataloged Procedure. A PROC statement is not mandatory to be coded in a cataloged procedure.
The library containing cataloged procedures is a partitioned data set (PDS) or a partitioned data set extended (PDSE).
When a cataloged procedure is called, the calling step receives a copy of the procedure. therefore, a cataloged procedure can be used simultaneously by more than one job.
If you are modifying a cataloged procedure, do not run any jobs that use the procedure during modification.
Let's see some examples for procedures in next chapter...
If you have any doubts or queries related to this chapter, get them clarified from our Mainframe experts on ibmmainframer Community!