Monday, March 8, 2010

5. PROCEDURE

• There are two types of procedures :
- Catalogue Procedures
- InStream Procedures

• CATALOGUED PROCEDURE is a member of a PDS which is often refered to as procedure library or PROCLIB.

• INSTREAM PROCEDURES contained within job's input stream.


INVOKING A PROCEDURE

//PR EXEC ABC
OR
//PR EXEC PROC = ABC

RESTRICTIONS

- max 255 steps

• The following are not permitted to reside in a procedure :
- JOB Statement
- An EXEC statement invoking a procedure
- JOBLIB
- JOBCAT
- DD * or DATA
- // null statement
- A PEND statement

Common Rules for EXEC & DD Statement to Override for JCL Procedures

• A parameter can be replaced, added or nullified

• When replacing an existing parameter, the overriding parameter must be specified in its complete format. DCB is an exception

• An overriding parameter replaces the same parameter, if it exists. It is added to the statement if it does not exist.

• A syntactical JCL error inside a procedure cannot be corrected by overriding the erroneous parameter.

• To nullify an existing parameter "parameter" = must be coded

• To override any parameters in an concatenation other than the first one, the following must be coded :

//stepname.ddname DD
// DD
// .
// .
// DD overriding parameters

• To add an entire DD statement
// stepname.ddname DD complete parameter field.


RULES FOR EXEC STATEMENT OVERRIDING

• To override any parameter in a DD statement an independent DD statement must be supplied in the following format :

• The sequence of overriding DD statements must be the same as the sequence of the corresponding overridden statements. However, parameters within a DD statement need not be overridden in sequence.

• An additional DD statement must be the last one in a step's overriding statements.

• To override an EXEC parameter, " parameter.stepname=value" must be coded when adding or replacing a parameter and "parameter.stepname=" must be coded when nullifying a parameter.

• The PGM parameter cannot be overridden

• All overriding EXEC parameters must be coded in the EXEC statement that invokes the procedure.

• All overrides to EXEC parameters must be completed before overriding parameters in a subsequent step.



procedure lam

//S1 EXEC PGM=ED, PARM=(A,B,C,E)
// REGION=900K, TIME = (5,30)
//STEPLIB DD DSN=DEV.LOADLIB,DISP=SHR
//IN1 DD DSN=USER1.FILE2,DISP=SHR
//IN2 DD DSN=USER1.FILEX,DISP=OLD
// UNIT=TAPE, VOL=SER=000101
//REP DD SYSOUT =*,
//OUT DD DSN=USER1.PLA,DISP=(,CTLG,DELETE),
// UNIT=SYSDA, VOL=SER=BS3003
// SPACE=(CYL,(20.5),DCB=(BLKSIZE=4000,
// LRECL=80, RECFM=FB)

Required in step S1:

a) PARM must be (A,B,C,D) and TIME nullified
b) In IN1, DSN must be USER1.FILE3
c) IN2 must retrieve USER1.FILEX as a cataloged dataser
d) In OUT, BLKSIZE must be 23440

//S2 EXEC PGM=FORM, REGION=900K
//INA DD DSN=USER1.PLA,DISP=SHR
// DD DSN=USER1.F226,DISP=SHR
// DD DSN=USER1.F232,DISP=SHR
// DD DSN=USER1.F118,DISP=SHR
//OUTA DD DSN=USER.F323,DISP=(,CATLG,DELETE),
// UNIT=TAPE, VOL=SER=001110
// DCB=BLKSIZE=32700, LRECL=100,
// RECFM=FB)
//PRNT DD SYSOUT=*

Required in Step S2 :

a) COND = (0,LT) must be coded
b) In INA DSN in the third concatenation must be USER1.F228
c) In DD statement OUTA, UNIT be SYSDA
d) An entire DD statement :
//STEPLIB DD DSN=DEV.LOADLIB,DISP=SHR
must be coded.

//S3 EXEC PGM=REPO,REGION = 400K, COND=(O,LT)
//1N3 DD DSN=USER1.F333, DISP=OLD
//OUT3 DD DSN=USER1.F111,DISP=(,CRLG,DELETE),
// UNIT=SYSDA, VOL=SER=DEVO12,
// SPACE=(CYL,(50,15),RLSE),
// DC3=(BLKSIZE=23440,LRECL=80,RECFM=FB)
//PRINT DD SYSOUT =*
//



Required in Step S3 :

a) EVEN must be added to the COND parameter
b) In DD statement OUT3, RLSE must be removed from the SPACE parameter must be nullified.

SOME TYPICAL EXAMPLES

Example 1:

//S1 EXEC PGM=ONE
//OUT1 DD DSN=U1.S1,
// DISP=(,CTLG, DELETE),
// UNIT=TAPE
// DCB=(BLKSIZE=32700)



Required
OUT1 must be dummied

Override
//S.OUT1 DD DUMMY

Regardless of the contents, no other parameters are needed.

SOME TYPICAL EXAMPLES

Example 2 :

//S1 EXEC PGM=ONE
//IN1 DD DSN=U1.B1,DISP=SHR
// DD DSN=U2.B2,DISP=SHR
// DD DSN=U3.B3,DISP=SHR

Required
Second concatenation of INI must be dummy

Override
//S1.INI DD
DD DSN=U1.B3
DD DUMMY

Example 3:

//S1 EXEC PGM=ONE
//CNTL DD DSN=U1.CNTLIB(S1), DISP=SHR

Required
DD statement CNTL must be //CNTL DD*


Override
//S1.CNTL DD*

Regardless of the contents DD * will override all.


Example 4 :

//S1 EXEC PGM = ONE
//OVT4 DD DSN=U1.D1,DISP=NEW
// DISP=SYSDA,VOL=SER=TEST26,
// SPACE=CTRK,(500,50)),
// DCB=(BLKSIZE=23400,
// LRECL=100,RECFM=FB)

Required
DCB parameter must be eliminated

Override
//S1.OUT4 DD DCB=(BLKSIZE=LRECL=RECFM)


SYMBOLIC PARAMETERS & SYMBOLIC OVERRIDES

• Symbolic overrides can be used only when symbolic parameters have been coded inside the procedure

• A symbolic parameter is a name preceded by an ampersand (&)

• A symbolic parameter can be coded in place of any parameter, part of a parameter in the parameter field of an EXEC, DD or OUTPUT statement.

SYMBOLIC PARAMETER

Example 1 :

//S1 EXEC PGM=BL
//IN DD DSN=&H1..INFILE,DISP=SHR
//OUT DD DSN=&HQ..OUTFILE,DISP=,CATLG,DELETE),
// UNIT=SYSDA, DCB=(BLKSIZE=32700)

//PSK EXEC BLTX,HQ=PROD

- First period works as delimiter







Example 2 :

Procedure BLTX

//S1 EXEC PGM=BL
//IN DD DSN=&HQ…INFILE,DISP=SHR
//OUT DD DSN=&HQ…OUTFILE,DISP=,CATLG,DELETE
// UNIT=SYSDA,DCB(=BLKSIZE=32700)

//PSK EXEC BLTX,HQ='PROD.'

SYMBOLIC OVERRIDING

RULES FOR SYMBOLIC OVERRIDING

• An EXEC statement keyword (TIME, REGION etc.) cannot be used as a symbolic parameter.

• A symbolic override in either the EXEC or PROC statement that has no corresponding parameter in the procedure will result in a 'SYMBOL NOT DEFINED' JCL error.

• If a symbolic and a regular override conflict, the regular override always prevails.

• A symbolic parameter which is immediately followed by an alphabetic, numeric or national character must have a period at its end.

• A symbolic parameter can be coded many times in a procedure. When substitution occurs, all the occurrences will receive the same value.

• When nothing must be substituted for a symbolic parameter, "symbolic-override=' must be coded in the EXEC or PROC statement.

PROCEDURE SSP

//S1 EXEC PGM = P1, PARM = &PEL

Assume possible values that the PARM parameter can assume are ALD, BLD, CLD, etc.

//S1 EXEC PGM=P1, PARM = &PELLD

This will not work
Procedure SSP can be coded as

//S1 EXEC PGM=P1, PARM = PEL.LD

Now if the procedure is invoked

//A EXEC SSP, PEL=F

Substitution results in

//S1 EXEC PGM=P1, PARM = FLD

//S1 EXEC PGM = P1, PARM = &PEL

Example 1 :

//A EXEC SSP, PEL=FLD

Substitution results in

//S1 EXEC PGM=P1, PARM=FLD

Example 2 :

//B EXEC SSP, PEL = FLD, TIME = (5, 10)

substitution results in

//S1 EXEC PGM = P1, PARM=FLD, TIME = (5,10)

PROCEDURE SWP

//ABC PROCR=800K, Q=AUX, U=TAPE
//S1 EXEC PGM=P2, REGION=&R
//IN DD DSN=&Q..FILEX, DISP=SHR
//OUT DD DSN=&Q..FILEY, DISP=(,CATLG)
// UNIT = &U

//A EXEC SWP, Q=MAX

Substitution results in

//S1 EXEC PGM=P2, REGION=800K
//IN DD DSN=MAX.FILEX, DISP=SHR
//OUT DD DSN=MAX.FILEY, DISP=(,CATLG),
// UNIT =TAPE

THE PROC STATEMENT

• The purpose of the PROC statement is to contain symbolic override defaults.

• When a procedure is executed, the system will substitute symbolic parameters using symbolic overrides coded in the EXEC statement.

• For those symbolic overrides not found in the EXEC statement, the default symbolic overrides in the PROC statement will be used.



IN-STREAM PROCEDURES

• An in-stream procedures is a part of a job's input stream and exists only for the duration of the job.

• The PROC statement in an in-stream procedure is mandatory and serves two functions -
a) It signals the beginning of in-stream procedure
b) It contains default symbolic overrides.

• The PEND statement must be coded in an in-stream procedure to provide a delimiter

Remark :
1) A PROC statement in a catalogued procedure is optional. The only reason it is required is to contain default symbolic overrides.

Example :

//da0001ta JOB la2719,pcs,msgclass=A,
// msglevel=(1,1,),notify=da0001t
//* Instream prosedure
//procbr14 proc
//s1 exec pgm=iefbr14
//sysprint dd sysout=*
//dd1 dd dsn=da0001t.temp,
// disp=(old,delete)
// pend
//*
//step1 exec proc=procbr14
//s1.dd1 dd dsn=da0001t.temp1,
// disp=(,catlg,delete), unit=sysda,
// space=(trk,(2,1)),
// dcb=(1recl=80,recfm=fb,blksize=800)
//

Back to JCL Index
Back to home page

2 comments:

S.Saikishore said...

Hi, am using your tutorial.
it is easy to understandable mode.
pls update the remaining things also

S.Saikishore

hari2143@nani.com said...

Hello..
Thanks for posting material on JCL..
please post some material on COBOL...