Cataloged and in-stream procedures - IBM-JCL

For jobs that you run frequently or types of jobs that use the same job control, prepare sets of job control statements, called procedures.

1.In-stream Procedures
When you place a procedure in the job input stream, it is called an in-stream procedure. An in-stream procedure must begin with a PROC statement, end with a PEND statement, and include only the following other JCL statements: CNTL, comment, DD, ENDCNTL, EXEC, IF/THEN/ELSE/ENDIF, INCLUDE, OUTPUT JCL, and SET. You must observe the following restrictions regarding in-stream procedures:

  • Do not place any JCL statements (other than the ones listed above) or any JES2 or JES3 control statements in the procedure.
  • Do not place an in-stream data set (one that begins with DD * or DD DATA) in the procedure.
  • Do not define one in-stream procedure within another, that is, nested.
  • Do not use an in-stream procedure if the procedure will be run as a started job under the MASTER subsystem, that is, includes a JOB statement and is started via a START command such as S procname,SUB=MSTR.

2.Cataloged Procedures
A procedure that you catalog in a library is called a cataloged procedure. A cataloged procedure may consist of these JCL statements: CNTL, command, DD, ENDCNTL, EXEC, IF/THEN/ELSE/ENDIF, INCLUDE, OUTPUT JCL, and SET. Optionally, a cataloged procedure can begin with a PROC statement and end with a PEND statement. If coded, PROC must be the first statement in the procedure.

Cataloging a Procedure
The library containing cataloged procedures is a partitioned data set (PDS) or a partitioned data set extended (PDSE). The system procedure library is SYS1.PROCLIB. The installation can have many more procedure libraries with different names. You can also have procedures in a private library. The name of a cataloged procedure is its member name or alias in the library. When a cataloged procedure is called, the calling step receives a copy of the procedure; therefore, a cataloged procedure can be used simultaneously by more than one job. If you are modifying a cataloged procedure, do not run any jobs that use the procedure during modification. In a JES3 system, you can specify UPDATE on the JES3 //*MAIN statement to update a procedure library.

3.Using a Procedure
To execute a procedure, call it on an EXEC statement in an in-stream job. Specify the name of the procedure in the PROC parameter of the EXEC statement. The step uses the JCL statements in the procedure as if the JCL statements appeared in the input stream immediately following the EXEC statement. If necessary, you can modify the procedure for the current execution of the job step. When you call a procedure, the system retrieves it using the following search order:

  1. From the input stream
    If the called procedure is an in-stream procedure, the system retrieves it from the job input stream. You must place the in-stream procedure before the EXEC statement that calls it.
  2. From a private library
    If the called procedure is cataloged in a private library, the system retrieves it from the private library that you specify on the JCLLIB statement that appears earlier in the job stream.
  3. From the system library (in a non-APPC scheduling environment)
    If the called procedure is cataloged in a system library, the subsystem retrieves it as follows:
    • In JES2, from the library name on the PROCLIB= parameter on a JES2 /*JOBPARM statement.
    • In JES3, from the library name on the PROC= parameter of the JES3 //*MAIN statement.
    • In MSTR, the data set specified by the IEFPDSI DD statement in the currently active master JCL is searched for procedures. The default master JCL specifies SYS1.PROCLIB.

4.Testing a Procedure
Before putting a procedure into a system procedure library, you should test it. There are two ways to test a procedure:

  • Place a PROC statement before the procedure and a PEND statement after it and place it in a job input stream. For the test, call this in-stream procedure with an EXEC statement that appears later in the same job.
  • Put a procedure to be tested in a private library, identify the library on a JCLLIB statement, and call the procedure with an EXEC statement.

After testing a procedure, the type of environment in which you are running the job determines where you can catalog it.

  • In an APPC scheduling environment: Catalog the procedure in a private library, and define the library with a JCLLIB statement.
  • In a non-APPC scheduling environment: Catalog the procedure in the system procedure library SYS1.PROCLIB, an installation-defined procedure library, or a private library. Cataloging the procedure in the system procedure library allows anyone to use the procedure by calling it with an EXEC statement.

Cataloged and in-stream procedures are not checked for correct syntax until an EXEC statement that calls the procedure is checked for syntax. Therefore, a procedure can be tested only if an EXEC statement calls it.

All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd Protection Status

IBM-JCL Topics