Understanding Instream Procedures, Cataloged Procedures, and Symbolic Parameters in JCL
What Are Instream Procedures?
An in-stream procedure is written directly within the same JCL member where it is executed. It starts with a PROC statement and ends with a PEND statement. These procedures consist only of a limited set of JCL statements.
An in-stream procedure may include: CNTL,COMMENT,DD,END CNTL,EXEC,IF/THEN/ELSE/ENDIF,INCLUDE,SET
Written directly in the JCL between the PROC and PEND statements.
Must be defined before the step that executes the procedure.
Limited to the job in which it is defined
Example
//MYJOB JOB (12345),CLASS=A,MSGCLASS=X
//MYPROC PROC
//STEP1 EXEC PGM=IEFBR14
//STEP2 EXEC PGM=PROGRAM2
//PEND
//STEP3 EXEC PROC=MYPROC
Explanation
MYPROC - PROC: The instream procedure defined in the same JCL file.
PEND: Marks the end of the procedure.
EXEC PROC=MYPROC: Invokes the procedure in Step 3.
What Are Cataloged Procedures?
When the procedure is separated out from the JCL and coded in a different data set, it is called a Cataloged Procedure. A PROC statement is not mandatory to be coded in a cataloged procedure
Example
Suppose MYPROC is a cataloged procedure stored in a library. The JCL to invoke it is:
//MYJOB JOB (12345),CLASS=A,MSGCLASS=X
//JCLLIB ORDER=MY.PROC.LIB
//STEP1 EXEC PROC=MYPROC
Procedure Definition (Stored in MY.PROC.LIB)
//MYPROC PROC
//STEP1 EXEC PGM=IEFBR14
//STEP2 EXEC PGM=PROGRAM2
Explanation
JCLLIB ORDER=MY.PROC.LIB: Points to the library where the cataloged procedure is stored.
EXEC PROC=MYPROC: Executes the predefined steps in the cataloged procedure MYPROC
What Are Symbolic Parameters?
Symbolic parameters allow us to pass information from JCL to procedures (PROCs), making PROCs reusable with different values when calling from different JCLs.
They allow us to pass variable information from JCLs to procedures (PROCs) without changing the actual procedures (PROCs) code. This makes it easier to manage jobs and procedures that need to run with different parameters in different situations.
Symbolic parameters are placeholders or variables used in PROCs. They receive variable data from JCL, which replaces symbolic variables in PROC. Symbolic parameters can be defined and used in the same JCL.
This procedure is stored in a library (e.g., MY.PROC.LIB) and uses symbolic parameters for flexibility.
//COPYPROC PROC FILENAME=DEFAULT.DATA
//STEP1 EXEC PGM=IEBGENER
//SYSPRINT DD SYSOUT=*
//SYSUT1 DD DSN=&FILENAME,DISP=SHR
//SYSUT2 DD DSN=OUTPUT.FILE,DISP=(NEW,CATLG,DELETE),
// SPACE=(TRK,(5,5)),UNIT=SYSDA
JCL Invoking the Procedure
This job invokes the procedure COPYPROC and passes a specific value for the symbolic parameter FILENAME.
//MYJOB JOB (123),CLASS=A,MSGCLASS=X
//JCLLIB ORDER=MY.PROC.LIB
//STEP1 EXEC PROC=COPYPROC,FILENAME=MY.INPUT.DATA
Explanation
In the Procedure:
&FILENAME is a symbolic parameter with the default value DEFAULT.DATA.
In the Job:
When invoking COPYPROC, the value MY.INPUT.DATA is passed for &FILENAME.
This replaces the placeholder &FILENAME in the procedure.
Final Output: During execution, the following statements are generated:
//SYSUT1 DD DSN=MY.INPUT.DATA,DISP=SHR
//SYSUT2 DD DSN=OUTPUT.FILE,DISP=(NEW,CATLG,DELETE),
// SPACE=(TRK,(5,5)),UNIT=SYSDA
Last updated
Was this helpful?