Let's understand Mainframe
Home Tutorials Interview Q&A Quiz Mainframe Memes Contact us About us

Module 5: JCL PROCs Statement


Procedure

In Job Control Language, Procedures is pre-written segment of JCL codes which can be reused across application as and when needed simply by calling that particular procedure. Procedure may consist of multiple job steps that are very frequently used across the application. Procedure is one of the most important concept of JCL as it provides mean of reusability and consistency. Usually fixed set of JCL statements are coded in a procedure and the varying set of JCL statements are coded directly into JCL. The use of procedure helps in minimizing duplication of code and probability of error.

Syntax for defining Procedure:

//procName PROC <Group of JCL statements> //PEND

Where,

procName :- It identifies the name of the Procedure
PROC: - Defining procedure starts with keyword PROC
PEND:- This keyword is used to notify system about the end of procedure

Syntax for executing Procedure:

//stepName EXEC procName

Where,

stepName :- It is the name assigned to the job step
EXEC: - It is keyword which is used to call Procedure.
procName :- It is the name of the Procedure to be called

Example:-

//DEPTPROC PROC //STEP1 EXEC PGM=PROG1 //DATA1 DD DSN=DEPT1.EMP1.DATA1, // DISP=SHR //STEP2 EXEC PGM=PROG2 //DATA1 DD DSN=DEPT1.EMP1.DATA2, // DISP=SHR //PEND

In above example, STEP1 and STEP2 are common JCL steps which are getting used across multiple jobs, thus it’s better to code them in PROC instead of writing again and again in each JCL. In above example DEPTPROC is name of PROC, this name can be used to call this procedure

Below example shows how we can call DEPTPROC procedure in our job:-

//DEPTJOB JOB A123,’STEVE’ //PROCSTEP EXEC DEPTPROC

Rules for coding procedure:-

  • A procedure name can be 1 to 8 alphanumeric or national characters and first character of procedure name must be alphabetic or national.
  • Maximum of 255 job steps can be coded in procedure
  • Following JCL statements cannot be included
    • JOB
    • JOBLIB
  • In-stream data i.e. //SYSIN DD * or DD DATA is not allowed
  • An instream procedure cannot be coded inside procedure(an internal pair of PROC/PEND pair)

There are two ways in which Procedure can be coded and namely they are referred as In-Stream procedure and Cataloged procedure. As name suggests In-Stream procedure are coded with Job itself and thus scope of calling these procedure is limited only within that job, and in other hand Cataloged procedure is coded outside of job and placed inside a system or user defined library(generally in PDS) and thus it can be called from multiple jobs.






© copyright mainframebug.com
Privacy Policy