Reusable JCL collection
Previous topic | Next topic | Contents | Glossary | Contact z/OS | PDF


JCL EXEC statements: What are JCL procedures?

Reusable JCL collection

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.

Such a procedure is sometimes known as a cataloged procedure. A cataloged procedure is not related to the system catalog; rather, the name is a carryover from another operating system.

The following code shows an example of a JCL procedure (commonly called a proc).

//MYPROC   PROC
//MYSORT   EXEC PGM=SORT
//SORTIN   DD DISP=SHR,DSN=&SORTDSN
//SORTOUT  DD SYSOUT=*
//SYSOUT   DD SYSOUT=*
//         PEND
In this example procedure:
  • The PROC and PEND parameters identify the beginning and end of the JCL procedure. PROC is preceded by a label or name; in this example, the name is MYPROC. The PROC and PEND parameters are unique to procedures.
  • The first (and only) step in the procedure is the EXEC statement named MYSORT, which identifies the program SORT as the program to be run.
  • The SORTIN DD statement identifies the input data set containing data to be sorted. The variable &SORTDSN represents the input data set; its actual value will be determined by the JCL that calls in and uses this procedure.
  • The SORTOUT DD statement identifies the output data set where SORT is to place the sorted input; the SYSOUT=* parameter identifies a default data set.
  • The SYSOUT DD statement identifies a default data set in which the system is to place messages issued during the SORT program's processing.
If you coded JCL to use this example proc, your JCL might look like this:
//MYJOB    JOB 1
//*---------------------------------*
//MYPROC   PROC
//MYSORT   EXEC PGM=SORT
//SORTIN   DD DISP=SHR,DSN=&SORTDSN
//SORTOUT  DD SYSOUT=*
//SYSOUT   DD SYSOUT=*
//         PEND
//*---------------------------------*
//STEP1    EXEC MYPROC,SORTDSN=ZPROF.AREA.CODES
//SYSIN     DD *
SORT FIELDS=(1,3,CH,A)
In this example job:
  • Your JCL begins with a JOB statement that names your job MYJOB.
  • The first step in MYJOB, named STEP1, does two things:
    • Identifies MYPROC as the JCL procedure to be run.
    • Specifies the value SORTDSN=ZPROF.AREA.CODES as the value for the variable &SORTDSN.
  • The SYSIN DD statement provides instream instructions for the SORT program to use on the input data set, ZPROF.AREA.CODES.
The previous example shows how to change the value of one part of a JCL procedure; in this case, replacing the variable &SORTDSN with a real data set name ZPROF.AREA.CODES. In some cases, you might need to override an entire statement within a JCL procedure. To do so, you code a JCL PROC override statement, which is shown in this example:
//MYJOB     JOB 1
//*---------------------------------*
//MYPROC    PROC
//MYSORT    EXEC PGM=SORT
//SORTIN    DD DISP=SHR,DSN=&SORTDSN
//SORTOUT   DD SYSOUT=*
//SYSOUT    DD SYSOUT=*
//          PEND
//*---------------------------------*
//STEP1     EXEC MYPROC,SORTDSN=ZPROF.AREA.CODES
//MYSORT.SORTOUT DD DSN=ZPROF.MYSORT.OUTPUT,
//          DISP=(NEW,CATLG)
//SYSIN     DD *
SORT FIELDS=(1,3,CH,A)
The MYSORT.SORTOUT DD statement is a procedure override that redefines the output data set as a newly created data set rather than a default data set. The stepname.ddname format tells the system to override the corresponding DD statement in the named step, within the JCL procedure. Using an override allows you to tailor the procedure for your needs, without changing its function for other users.




Copyright IBM Corporation 1990, 2010