Explanation and concepts of JCL Procedure(s) include Instream, Catalogue, Nested procedures with examples.
JCL procedures are statements inside the JCL script to perform specific tasks. The fixed part of a JCL should reside in a procedure.
Using procedure, you can achieve parallel program execution with multiple files. You may want to create one JCL for each input file and call the procedure multiple times using different input file as symbolic parameters.
Syntax
Here is basic syntax of a JCL procedure definition:
//* //Step-name EXEC procedure-name
The contents of the procedure are reserved for JCL in-stream procedures. The content is stored in various base library members used in the cataloguing process. This chapter will explain the two types of procedures available in JCL, and finally, we will see how to insert different procedures.
Instream Procedure
When it’s coded inside JCL, it should be called instream procedure. Ideally, it should start with PROC and ends with PEND.
//MYJOBNAME JOB 1,CLASS=6,MSGCLASS=Y,NOTIFY=&SYSUID //* //INSTPRC1 PROC //PROC1 EXEC PGM=SORT //SORTIN DD DSN=&DSNAME,DISP=SHR //SORTOUT DD SYSOUT=MYINCL //SYSOUT DD SYSOUT=* //SYSIN DD DSN=&DATAC LRECL=80 // PEND //STEP1 EXEC INSTPRC1,DSNME=MYDATA.LIB.INPUT1, // DATAC=MYDATA.BASE.LIB1(DATA1) //* //STEP2 EXEC INSTPRC1,DSNME=MYDATA.LIB.INPUT2 // DATAC=MYDATA.BASE.LIB1(DATA1) //*
Explanation of the above example:
In the above example, the procedure INSTPRC1 is called on STEP1 and STEP2 with different input files. When calling the procedure, the DSNAME and DATAC parameters can be encoded with different values, they are called symbolic parameters. Various JCL inputs such as filenames, datamaps, PARM values, etc. are passed to the procedure as symbolic parameters.
When encoding symbolic parameters, do not use KEYWORDS, PARAMETERS, or SUBPARAMETERS as symbolic names. Example: Don’t use TIME=&TIME, but yes, you can use TIME=&TM, which is considered the correct way to encode symbols.
User-defined symbol parameters are called JCL symbols. There are symbols called system symbols that are used to perform login operations. The only system symbol commonly used by users in batch jobs is &SYSUID, which is used in the NOTIFY parameter of the JOB statement.
Cataloged Procedure
When a procedure is separated from the JCL and coded in a different data store, it is called a catalog procedure. PROC statements do not need to be coded during the cataloging process. Here is an example of JCL that calls the CATLPRC1 procedure:
//JOBNAME JOB 1,CLASS=6,MSGCLASS=Y,NOTIFY=&SYSUID //* //STEP EXEC CATLPRC1,PROG=CATPRC1,DSNME=MYDATA.LIB.INPUT // DATAC=MYDATA.BASE.LIB1(DATA1)
Here the CATLPRC1 procedure is cataloged in MYCOBOL.BASE.LIB1. PROG, DATAC, and DSNAME are passed as symbolic parameters to procedure CATLPRC1.
//CATLPRC1 PROC PROG=,BASELB=MYCOBOL.BASE.LIB1 //* //PROC1 EXEC PGM=&PROG //STEPLIB DD DSN=&BASELB,DISP=SHR //IN1 DD DSN=&DSNAME,DISP=SHR //OUT1 DD SYSOUT=* //SYSOUT DD SYSOUT=* //SYSIN DD DSN=&DATAC //*
During this process, the symbolic parameters PROG and BASELB are coded. Note that the PROG parameter in the procedure is overridden with a value in JCL; therefore, PGM takes the value CATPRC1 during execution.
Nested Procedures
As its name says, NESTED – that means when you call a proc from another proc – it is called a nested procedure.
Programs can be nested up to 15 levels. Nesting can be completed in a stream or a directory. We cannot write flow routines during catalog creation.
//SAMPINST JOB 1,CLASS=6,MSGCLASS=Y,NOTIFY=&SYSUID //* //SETNM SET DSNM1=INPUT1,DSNM2=OUTPUT1 //INSTPRC1 PROC //* START OF PROCEDURE 1 //STEP1 EXEC PGM=SORT,DISP=SHR //SORTIN DD DSN=&DSNM1,DISP=SHR //SORTOUT DD DSN=&DSNM2,DISP=(,PASS) //SYSOUT DD SYSOUT=* //SYSIN DD DSN=&DATAC //* //STEP2 EXEC PROC=INSTPRC2,DSNM2=MYDATA.LIB.OUTPUT2 // PEND //* END OF PROCEDURE 1 //* //INSTPRC2 PROC //* START OF PROCEDURE 2 //STEP1 EXEC PGM=SORT //SORTIN DD DSN=.INSTPRC1.STEP1.SORTOUT //SORTOUT DD DSN=&DSNM2,DISP=OLD //SYSOUT DD SYSOUT= //SYSIN DD DSN=&DATAC // PEND //* END OF PROCEDURE 2 //* //JSTEP1 EXEC INSTPRC1,DSNM1=MYDATA.LIB.INPUT1, // DATAC=MYDATA.BASE.LIB1(DATA1) //*
In the above example, the JCL calls procedure INSTPRC1 in procedure JSTEP1 and procedure INSTPRC2 in procedure INSTPRC1. Here the output from INSTPRC1 (SORTOUT) is sent as input (SORTIN) to INSTPRC2.
Let’s try to understand it a little better with these below additional concepts:
- The SET statement is used to define common symbols in work steps or procedures. It initializes the previous value in the symbol name. It must be defined before the first use of the symbol name in JCL.
- When INSTPRC1 is called in JCL JSTEP1, DSNM1=MYDATA.LIB.INPUT1 and DSNM2=OUTPUT1., the values initialized in the SET statement are reset to the values set in any job step/procedure.
- When calling INSTPRC2 INSTPRC1 STEP 2, DSNM1=MYDATA.LIB.INPUT1 and DSNM2=MYDATA.LIB.OUTPUT2.
- When INSTPRC1 is called in JCL JSTEP1, DSNM1=MYDATA.LIB.INPUT1 and DSNM2=OUTPUT1., the values initialized in the SET statement are reset to the values set in any job step/procedure.
Leave a Reply Cancel reply