Tuesday, 9 April 2019

JCL Cataloged Procedure: PROC, JCLLIB, and Override Examples

//RUNRPT EXEC PROC=MYRPT,HLQ=TEST01 can expand into several job steps without copying those steps into every job. The reusable statements live in a procedure-library member, while the calling job supplies values and overrides for one execution.

JCL cataloged procedure flow from PROCLIB through EXEC PROC to expanded JCL
Store once, invoke where needed.

What is a JCL cataloged procedure?

A JCL cataloged procedure is a named set of reusable JCL statements stored as a member of a partitioned data set or PDSE that participates in the procedure-library search. The member usually contains one or more EXEC statements and their DD statements. A job calls the member by name rather than repeating the stored statements.

IBM describes SYS1.PROCLIB as a standard system procedure library, but production installations commonly concatenate product and application procedure libraries with it. Do not place an application procedure in SYS1.PROCLIB simply because an example uses that name. Follow the library, change-control, and security rules at your site.

Cataloged procedure versus in-stream procedure

PointCataloged procedureIn-stream procedure
LocationA member in a procedure libraryInside the submitted job
ReuseAvailable to jobs allowed to search the libraryAvailable only within that job
End markerNo PEND is required in the library memberThe definition ends with PEND
Best fitControlled compile, link-edit, backup, utility, and application-run standardsTesting a procedure or keeping a one-job definition close to its caller

For the broader procedure concepts, see the JCL procedure tutorial. The in-stream procedure guide covers the inline form.

Create a cataloged procedure member

Create a member such as USER01.PROCLIB(MYRPT). The member name becomes the procedure name used by the calling EXEC statement. The following procedure runs a reporting program and provides defaults through symbolic parameters.

//MYRPT   PROC HLQ=PROD01,OUTCLS=A
//REPORT  EXEC PGM=RPT100
//STEPLIB DD  DSN=&HLQ..LOAD,DISP=SHR
//INFILE  DD  DSN=&HLQ..INPUT.CUSTOMER,DISP=SHR
//RPTFILE DD  SYSOUT=&OUTCLS
//SYSPRINT DD SYSOUT=*

&HLQ. uses a period to terminate the symbolic name before the next period in the data set name. With the default HLQ=PROD01, &HLQ..LOAD resolves to PROD01.LOAD.

Cataloged-member rule: a stored procedure may begin with a named PROC statement, but it does not need the PEND statement used by an in-stream procedure.

Make a private PROCLIB searchable with JCLLIB

If the member is not in an installation-defined procedure-library concatenation, code JCLLIB ORDER after the JOB statement and before the first EXEC statement. IBM states that the named libraries are searched in the coded order before unspecified default procedure libraries.

//RPTJOB  JOB (ACCT),'DAILY REPORT',CLASS=A,MSGCLASS=X
//PROCS   JCLLIB ORDER=(USER01.PROCLIB,TEAM01.PROCLIB)
//RUNRPT  EXEC PROC=MYRPT

This job searches USER01.PROCLIB first, then TEAM01.PROCLIB, followed by any applicable default libraries. JCLLIB identifies procedure and INCLUDE libraries; it does not replace JOBLIB or STEPLIB for executable load modules.

Invoke the procedure with EXEC PROC

Both forms below call a procedure named MYRPT. Coding PROC= is explicit and easier for a beginner to recognize.

//RUNRPT  EXEC PROC=MYRPT
//RUNRPT  EXEC MYRPT

The name before EXEC, RUNRPT, identifies this invocation in the job. The step names inside the procedure keep their own identities after expansion. The JCL EXEC statement guide explains the difference between PGM= and PROC=.

Override symbolic parameters

Values coded on the calling EXEC statement replace the defaults on the PROC statement for that invocation. The stored member is not changed.

//RUNRPT  EXEC PROC=MYRPT,HLQ=TEST01,OUTCLS=H

The expanded data set names use TEST01, and the report is routed to SYSOUT class H. Choose descriptive symbols and provide safe defaults only when a default is appropriate. See JCL positional and keyword parameters for the statement-field rules.

Override a DD statement in a cataloged procedure

Qualify the override with the procedure step name and DD name. Here, REPORT is the EXEC step inside MYRPT, and INFILE is its DD name.

//RUNRPT         EXEC PROC=MYRPT,HLQ=TEST01
//REPORT.INFILE  DD   DSN=TEST01.INPUT.SPECIAL,DISP=SHR

IBM notes that an override replaces only the parameters you code. Parameters not replaced can remain from the stored DD statement. If a complete replacement is intended, inspect the expanded JCL so that an inherited UNIT, VOL=SER, SPACE, or DCB subparameter does not survive unexpectedly.

Procedure DD overrides must follow the procedure invocation. When several DD statements are overridden, keep them in the same relative order as their statements in the procedure. The JCL DD statement guide provides allocation examples.

Add a DD statement for one invocation

A calling job can add a DD statement to a procedure step when the stored procedure does not contain that DD name.

//RUNRPT          EXEC PROC=MYRPT
//REPORT.SYSUDUMP DD   SYSOUT=*

This adds SYSUDUMP to step REPORT for the current call. It does not add the statement to the procedure member. Use the feature for job-specific diagnostic or input/output requirements, not as a substitute for fixing a procedure that is wrong for every caller.

Complete cataloged procedure example

Procedure member USER01.PROCLIB(MYRPT)

//MYRPT   PROC HLQ=PROD01,OUTCLS=A
//REPORT  EXEC PGM=RPT100
//STEPLIB DD  DSN=&HLQ..LOAD,DISP=SHR
//INFILE  DD  DSN=&HLQ..INPUT.CUSTOMER,DISP=SHR
//RPTFILE DD  SYSOUT=&OUTCLS
//SYSPRINT DD SYSOUT=*

Calling job

//RPTJOB  JOB (ACCT),'DAILY REPORT',CLASS=A,MSGCLASS=X
//PROCS   JCLLIB ORDER=USER01.PROCLIB
//RUNRPT  EXEC PROC=MYRPT,HLQ=TEST01,OUTCLS=H
//REPORT.INFILE  DD DSN=TEST01.INPUT.SPECIAL,DISP=SHR
//REPORT.SYSUDUMP DD SYSOUT=*

The job locates MYRPT, substitutes the symbolic values, overrides REPORT.INFILE, adds REPORT.SYSUDUMP, and submits the expanded steps to normal JCL conversion and execution.

Watch the JCL cataloged procedure video

Video walkthrough: creating and using a JCL cataloged procedure.

Common cataloged procedure errors

  • Procedure not found: the member name is wrong or its library is missing from the applicable search order.
  • Wrong procedure step name: an override uses the calling step name instead of the EXEC step name inside the procedure.
  • Unresolved symbol: the procedure references a symbol that has no default and the caller supplies no value.
  • Bad symbol delimiter: a data set name omits the terminating period after a symbolic parameter.
  • Override order error: multiple DD overrides do not follow the order of the original DD statements.
  • Invalid stored JCL: IBM states that an invalid parameter in the original procedure cannot be repaired by an override because the base procedure is checked first.
  • Program not found: JCLLIB found the procedure, but JOBLIB or STEPLIB does not make the requested load module available.
Before production: review the expanded JCL in JES, confirm the resolved data set names, and check that every override landed on the intended procedure step.

Cataloged procedure test checklist

  1. Validate the member name and the PROC statement name.
  2. Confirm which PROCLIB concatenation or JCLLIB ORDER supplies the member.
  3. List each symbolic parameter, its default, and the value supplied by the caller.
  4. Match every override to the internal procstep.ddname.
  5. Check the expanded JCL before diagnosing the application program.
  6. Keep environment-specific data set names in symbols or approved overrides.

For a beginner sequence covering JOB, EXEC, and DD statements, use the JCL tutorial with examples.

Official IBM references

JCL cataloged procedure FAQ

What is a JCL cataloged procedure?

A cataloged procedure is a reusable set of JCL statements stored as a member of a procedure library. A job invokes the member from an EXEC statement.

How do I call a cataloged procedure?

Code EXEC PROC=procedure-name, or omit PROC= and code the procedure name as the EXEC positional parameter. Add any symbolic values on the same EXEC statement.

How does JCLLIB ORDER affect a cataloged procedure?

JCLLIB ORDER lists private or system procedure libraries in search order. z/OS searches those libraries before unspecified default procedure libraries.

Does a DD override change the stored procedure?

No. An override applies only to the current invocation. The procedure member in the library is not changed.

The safest procedure call is the one whose expanded JCL you have reviewed; the member name alone does not show the data sets, defaults, and overrides that the job will use.

No comments:

Post a Comment

New In-feed ads