RAMESH KRISHNA REDDY mainframe discussion forum - cobol, db2,cics,jcl,file-aid,changeman,... interview questions, quizs
Online Tutorials   | PREV  | TOP  | NEXT





1. Introduction

2. Instream Procedure

3. Cataloged procedure

4. Modify statements in a procedure

5. Symbolic parameters


   In JCL, We have an important concept reusability in the form of 
   Instream and Cataloged procedures, Often, in work environments 
   users can utilized same JCL. Using instream / cataloged procedures 
   we can reuse the jcl code which was stored in another data set, in 
   our data set. 

   Syntax for Executing procedure  

   -->   EXEC  [PROC=]procedure-name


   A JCL Procedure is a pre-written segment of code, that you can include 
   in your JOB. You code instream data set within the job and use it in 
   that job as many times as you want.

   An Instream Procedure JCL Example



   - Instream procedure should be defined , before any EXEC statement defined
   - Instream procedure startes with PROC and ends with PEND statements

   - Instream procedure is executed when we main jcl called. 

The maximum number of instream procedures you can in any job is 15

CATALOGED PROCEDURES Pre-written segment of code (which is stored as an member of PDS), which you can use as many times you want in any job in the system. IBM supplies a utility program called IEBUPDTE; this program places cataloged procedures into partitioned data sets. These procedures are placed inside a system library called SYS1.PROCLIB. Developing Catalog Procedure STEP1: Write an Cataloged procedure in MYLIB.EXAMPLES.TEST(CATALOG1) //CATLOG1 PROC //STEP1 EXEC PGM=COBPROG //INFILE DD DSN=TEST.GLOB.LIB, // DISP=SHR //OUTFILE DD DSN=TEST.GLOB.SPACE.LIB, // DISP=SHR STEP2 : Write Main JCL which will call out CATALOG1 JCL //MYJOB JOB (WE234),'RAMESH',CLASS=A // JCLLIB ORDER=(MYLIB.EXAMPLES.TEST) <-- Attention //STEP1 EXEC CATALOG1 <-- Attention // EXPLANATION - When you executing CATALOGED PROCEDURE, If you not specified where it is with JCLLIB statement , it will serach for this procedure in system procedure library SYS1.PROCLIB - There many IBM-supplied procedures that compile, link, and run programs
Job will search the JCLLIB libraries first, in the order in which they�re coded. If the procedure is not found in any of the named libraries, SYS1.PROCLIB is searched.
The following statements cannot be included within the procedure
JES2 or JES3 control statements
MODIFY STATEMENTS IN A PROCEDURE There are times, when we want to change procedure statements according to our requirement, IBM provided a way without changing actual procedure, we can add/modify contents of procedure. Let us discuss what are the ways There are two types of modification we can do , 1. on EXEC statement 2. on DD statement on EXEC statement We can do following functions on EXEC statement in a procedure - Modify parameter on EXEC statements PROCEDURE STATEMENT - //STEP10 EXEC PGM=COBPROG,TIME=30 PARAMETER OVERRIDE - //MYSTEP EXEC PROC=MYPROC,TIME.STEP10=40 Now Resultant TIME value for that step (in proc) is 40 - Adding parameter to an EXEC statement / all EXEC statement PROCEDURE STATEMENT - //STEP10 EXEC PGM=COBPROG,TIME=30 PARAMETER ADDING - //MYSTEP EXEC PROC=MYPROC,REGION.STEP10=56K (for single step) REGION will be added to the STEP10 in MYPROC procedure PARAMETER ADDING - //MYSTEP EXEC PROC=MYPROC,REGION=56K (for single step) If REGION is not available for any step in that procedure. REGION will be added to all steps in procedure. If REGION is available for any step in procedure, REGION value will be override existing value on that step. - Nullifying the parameter value PROCEDURE STATEMENT - //STEP10 EXEC PGM=COBPROG,TIME=30 PARAMETER ADDING - //MYSTEP EXEC PROC=MYPROC,TIME.STEP10= Dont give any value for that parameter, it will nullifying that parameter value in procedure on DD statement - Syntax for add/modify DD statements in a procedure //name EXEC [PROC=]procedure-name //[procstepname].ddname DD parameter=value // We can do following functions on EXEC statement in a procedure using above syntax - Modify existing parameter on DD statements within a procedure - Add parameter to existing DD statement within a procedure - Add DD statement to a job step - Nullify the effect of parameter on DD statement in a procedure SYMBOLIC PARAMETERS Usaually, the same JCL can be used by different programmers to implement common tasks, such as the opening, reading, and writing of data sets. In those cases , we can use symbolic parameters. Using symbolic parameters we can pass value to a parameter which is used in procedure. A symbolic parameter on a DD statement is coded the parameter preceded by an ampersand. Syntax for assigning values to symbolic parameters in a procedure //[name] EXEC [PROC=]procedure-name,symbolic-parameter=value EXAMPLE JCL -> Procedure which is using symbolic parameter //MYPROC PROC //MYSTEP EXEC PGM=COBPROG //INFILE DD DSN=&DOC..TEST.LIB,DISP=SHR //OUTFILE DD DSN=&DOC..TEST.OUT, // DISP=(NEW,KEEP,DELETE), // UNIT=SYSDA, // SPACE=(CYL,(&SPACE)) The invoking EXEC statement //STEPA1 EXEC MYPROC,DOC=MYLIB,SPACE='10,5' The effective JCL //MYPROC PROC //MYSTEP EXEC PGM=COBPROG //INFILE DD DSN=MYLIB.TEST.LIB,DISP=SHR //OUTFILE DD DSN=MYLIB.TEST.OUT, // DISP=(NEW,KEEP,DELETE), // UNIT=SYSDA, // SPACE=(CYL,('10,5')) EXPLANATION - In above example, &DOC,&SPACE are symbolic parameters in MYPROC procedure We are passing values from invoking JCL,these value will be override the &DOC and &SPACE where ever they find in the procedure NEXT CHAPTER TOPIC : GDG (Generation Data Group)

Previous chapter in jcl tutorial Starting of jcl tutorial Next chapter in jcl tutorial

Visit jcl books section in this site for good books

Home | Donations | Online Tutorials | Books | Entertainment | Contactme | privacy | sql tutorial | jcl interview questions | JCL Tutorial | JCL Tutorial - chapter1 | JCL Tutorial - chapter2 | JCL Tutorial - chapter3 | JCL Tutorial - chapter4 | JCL Tutorial - chapter5 | JCL Tutorial - chapter6 | JCL Tutorial - chapter7 | JCL Tutorial - chapter8 | JCL Tutorial - chapter9 | JCL Tutorial - chapter10 | JCL Tutorial - chapter11