A JCL procedure (or proc) is a pre-defined set of JCL statements that can be reused across multiple jobs. Procedures enhance productivity, reduce errors, and simplify maintenance by allowing common job steps to be written once and used repeatedly.
A JCL procedure can contain most JCL statements including EXEC, DD, OUTPUT, and comment statements. It cannot contain a JOB statement, another PROC statement, or a null statement.
123456//procname PROC [parameter1=default1,parameter2=default2,...] //step1 EXEC PGM=program1 //DD1 DD ... //step2 EXEC PGM=program2 //DD2 DD ... // PEND
An in-stream procedure begins with a PROC statement and ends with a PEND statement. A cataloged procedure typically doesn't include the PROC and PEND statements in the library, although they may be shown in documentation.
The PROC statement marks the beginning of a procedure and can define symbolic parameters with default values:
Format:
1//procname PROC param1=value1,param2=value2,...
Examples:
123//MYPROC PROC //SORTPROC PROC SORTIN=INPUT,SORTOUT=OUTPUT,PGM=SORT //COPYPROC PROC FROM=,TO=,SPACE=(TRK,(10,5))
The PROC statement can define parameters with or without default values. Parameters without default values must be provided when the procedure is executed.
The PEND statement marks the end of a procedure definition:
Format:
1// PEND
The PEND statement is only required for in-stream procedures and is not included in cataloged procedures stored in procedure libraries.
A procedure typically contains one or more EXEC statements and associated DD statements. It may also contain:
A procedure cannot contain:
Procedures can be defined in-stream or cataloged in a procedure library for broader use.
An in-stream procedure is defined directly within the JCL job:
12345678910111213//MYJOB JOB (ACCT),'USER',CLASS=A //* //* DEFINE THE PROCEDURE //MYPROC PROC TYPE='MASTER',CLASS=A //STEP1 EXEC PGM=MYPROG //INPUT DD DSN=&TYPE..DATA,DISP=SHR //OUTPUT DD SYSOUT=&CLASS //REPORT DD SYSOUT=&CLASS // PEND //* //* EXECUTE THE PROCEDURE //STEP01 EXEC MYPROC //STEP02 EXEC MYPROC,TYPE='DETAIL',CLASS=B
In this example, the procedure MYPROC is defined with two parameters (TYPE and CLASS) and then executed twice with different parameter values.
To catalog a procedure in a procedure library, you need to use a utility such as IEBUPDTE or submit the procedure to a specific procedure library:
123456789101112//CATALOG JOB (ACCT),'USER',CLASS=A //STEP1 EXEC PGM=IEBUPDTE,PARM=NEW //SYSPRINT DD SYSOUT=* //SYSUT2 DD DSN=SYS1.PROCLIB,DISP=SHR //SYSIN DD * ./ ADD NAME=MYPROC,LIST=ALL //MYPROC PROC TYPE='MASTER',CLASS=A //STEP1 EXEC PGM=MYPROG //INPUT DD DSN=&TYPE..DATA,DISP=SHR //OUTPUT DD SYSOUT=&CLASS //REPORT DD SYSOUT=&CLASS /*
This job adds the procedure MYPROC to the system procedure library SYS1.PROCLIB. Note that the PEND statement is typically not included when cataloging a procedure.
To execute a procedure, use the EXEC statement with the procedure name:
Format:
12//stepname EXEC procname[,param1=value1,param2=value2,...] //stepname EXEC PROC=procname[,param1=value1,param2=value2,...]
Examples:
123//STEP1 EXEC MYPROC //STEP2 EXEC MYPROC,TYPE='DETAIL' //STEP3 EXEC PROC=SORTPROC,SORTIN=MY.FILE,SORTOUT=MY.OUTPUT
The PROC= keyword is optional. Parameter values specified on the EXEC statement override the defaults defined in the procedure.
Symbolic parameters allow for flexibility in procedures by letting you substitute values when the procedure is executed.
Symbolic parameters are defined on the PROC statement or with SET statements:
123//MYPROC PROC A=1,B='ABC',C= // SET D=100 //STEP1 EXEC PGM=MYPROG,PARM='&A,&B'
Symbolic parameters are referenced by prefixing their names with an ampersand (&):
1234//MYPROC PROC DSN='MY.DATASET',SPACE=(TRK,(10,5)) //STEP1 EXEC PGM=IEFBR14 //DD1 DD DSN=&DSN,DISP=(NEW,CATLG,DELETE), // SPACE=&SPACE,UNIT=SYSDA
In this example, the DSN and SPACE parameters are used within the DD statement. When executing the procedure, these values can be overridden.
When a symbolic parameter is followed by a period in a dataset name, use double periods:
123//MYPROC PROC PREFIX='MY' //STEP1 EXEC PGM=IEFBR14 //DD1 DD DSN=&PREFIX..DATA,DISP=SHR
In this example, if PREFIX is 'MY', the dataset name will be MY.DATA. The double period is needed because the first period is considered part of the parameter substitution.
You can override or add to statements in a procedure when you execute it.
To override parameters on an EXEC statement within a procedure:
1//STEP1 EXEC MYPROC,PARM.STEP1='NEW VALUE',TIME.STEP2=5
This overrides the PARM parameter for STEP1 and the TIME parameter for STEP2 within the MYPROC procedure.
To override a DD statement in a procedure, specify the procedure step name and the ddname:
1//STEP1.DD1 DD DSN=NEW.DATASET,DISP=SHR
This overrides the DD1 statement in STEP1 of the procedure. The entire DD statement is replaced, not just individual parameters.
To add a DD statement to a procedure step:
1//STEP1.NEWDD DD DSN=EXTRA.DATASET,DISP=SHR
This adds a new DD statement named NEWDD to STEP1 of the procedure.
To nullify (ignore) a DD statement in a procedure:
1//STEP1.DD1 DD DUMMY
This replaces the DD1 statement in STEP1 with a DUMMY, effectively nullifying it.
Here are some examples of commonly used procedures.
12345678910111213141516//COPYPROC PROC FROM=,TO=,SPACE=(TRK,(10,5)) //* //* PROCEDURE TO COPY ONE DATASET TO ANOTHER //* //COPY EXEC PGM=IEBGENER //SYSPRINT DD SYSOUT=* //SYSIN DD DUMMY //SYSUT1 DD DSN=&FROM,DISP=SHR //SYSUT2 DD DSN=&TO,DISP=(NEW,CATLG,DELETE), // SPACE=&SPACE,UNIT=SYSDA, // DCB=(RECFM=FB,LRECL=80,BLKSIZE=27920) // PEND //* EXECUTION EXAMPLE: //STEP1 EXEC COPYPROC,FROM='MY.INPUT.FILE',TO='MY.OUTPUT.FILE', // SPACE=(CYL,(2,1))
This procedure copies one dataset to another using IEBGENER, with parameters for input/output files and space allocation.
1234567891011121314151617181920212223242526//SORTPROC PROC SORTIN='SORTIN',SORTOUT='SORTOUT', // SORTWK01='SORTWK01',SORTWK02='SORTWK02', // SORTWK03='SORTWK03',SORTCNTL='SORTCNTL' //* //* PROCEDURE TO SORT DATA //* //SORT EXEC PGM=SORT //SYSOUT DD SYSOUT=* //SORTIN DD DSN=&SORTIN,DISP=SHR //SORTOUT DD DSN=&SORTOUT,DISP=(NEW,CATLG,DELETE), // SPACE=(CYL,(5,2)),UNIT=SYSDA, // DCB=(RECFM=FB,LRECL=80,BLKSIZE=27920) //SORTWK01 DD DSN=&&SORTWK01,DISP=(NEW,DELETE), // SPACE=(CYL,(10,5)),UNIT=SYSDA //SORTWK02 DD DSN=&&SORTWK02,DISP=(NEW,DELETE), // SPACE=(CYL,(10,5)),UNIT=SYSDA //SORTWK03 DD DSN=&&SORTWK03,DISP=(NEW,DELETE), // SPACE=(CYL,(10,5)),UNIT=SYSDA //SYSIN DD DSN=&SORTCNTL,DISP=SHR // PEND //* EXECUTION EXAMPLE: //STEP1 EXEC SORTPROC,SORTIN='MY.DATA',SORTOUT='MY.SORTED.DATA' //SORT.SYSIN DD * SORT FIELDS=(1,10,CH,A) /*
This procedure performs a sort operation using the SORT utility. It includes parameters for input/output files and work files, and allows for overriding the SYSIN DD statement to provide sort control statements.
123456789101112131415161718192021222324252627282930313233343536373839//COBCLG PROC SYSLIB='SYS1.COBLIB', // SOURCE='SOURCE.COBOL',LOADLIB='USER.LOADLIB', // PARM.COB='NOOPT,OBJECT,NODYNAM', // PARM.LKED='LIST,MAP,LET', // REGION.COB=2M,REGION.LKED=2M,REGION.GO=4M //* //* PROCEDURE TO COMPILE, LINK, AND EXECUTE A COBOL PROGRAM //* //COB EXEC PGM=IKFCBL00,REGION=®ION.COB, // PARM='&PARM.COB' //SYSPRINT DD SYSOUT=* //SYSUT1 DD UNIT=SYSDA,SPACE=(CYL,(1,1)) //SYSUT2 DD UNIT=SYSDA,SPACE=(CYL,(1,1)) //SYSUT3 DD UNIT=SYSDA,SPACE=(CYL,(1,1)) //SYSUT4 DD UNIT=SYSDA,SPACE=(CYL,(1,1)) //SYSLIN DD DSN=&&LOADSET,DISP=(MOD,PASS), // UNIT=SYSDA,SPACE=(TRK,(3,3)) //SYSIN DD DSN=&SOURCE,DISP=SHR //* //LKED EXEC PGM=IEWL,REGION=®ION.LKED, // PARM='&PARM.LKED',COND=(4,LT,COB) //SYSPRINT DD SYSOUT=* //SYSUT1 DD UNIT=SYSDA,SPACE=(CYL,(1,1)) //SYSLIB DD DSN=&SYSLIB,DISP=SHR //SYSLMOD DD DSN=&LOADLIB(PROGRAM),DISP=SHR //SYSLIN DD DSN=&&LOADSET,DISP=(OLD,DELETE) // DD DDNAME=SYSIN //* //GO EXEC PGM=*.LKED.SYSLMOD,REGION=®ION.GO, // COND=((4,LT,COB),(4,LT,LKED)) //STEPLIB DD DSN=&LOADLIB,DISP=SHR //SYSOUT DD SYSOUT=* //SYSUDUMP DD SYSOUT=* // PEND //* EXECUTION EXAMPLE: //STEP1 EXEC COBCLG,SOURCE='MY.COBOL.PROGRAM' //GO.INPUT DD DSN=MY.INPUT.FILE,DISP=SHR //GO.OUTPUT DD SYSOUT=*
This procedure compiles, links, and executes a COBOL program. It includes parameters for source code location, load library, and options for each step. It also uses conditional execution to skip steps if previous steps fail.
Follow these guidelines when creating and using JCL procedures.
Problem | Recommendation |
---|---|
Missing required parameters | Document required parameters clearly and check for them |
Hardcoded values | Use symbolic parameters for values that might need to change |
Too many parameters | Limit parameters to what's truly needed for flexibility |
Unclear naming | Use descriptive names for procedures and parameters |
Inflexible procedures | Design procedures with reasonable customization options |
Inadequate documentation | Include clear comments explaining purpose and usage |
Symbolic parameter conflicts | Use unique parameter names to avoid conflicts |