Legacy Manifram Training-3

You might also like

Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1of 27

Procedures

Procedures

Procedure

Types of procedures

The Procedure statements

The Symbolic Parameters

2
PROCEDURES

Procedures A procedure is a set of standard JOB step


definitions that can be used repeatedly to perform a
FUNCTION

Procedures are invoked by EXEC statements

Procedures comprise standard JOB step definitions and:


PROC statement
PEND statement
Symbolic parameters

3
PROCEDURES

Two types of procedures:

1) Cataloged procedures

2)In stream procedures

4
Catalog Procedures
Set of JCL Stmt’s that are grouped together and then
recorded as a member of partitioned dataset. This
partitioned dataset can be included in the JCL with JCLLIB
stmt.
String of JCL statements defined as a member of one of the
procedure libraries, usually SYS1.PROCLIB.
Procedure referenced by the name of the member in the
cataloged library
Can be used by any number of jobs

5
In stream Procedures

Set of JCL Stmt’s that are included in the Input stream


of Job itself
Completely contained within a JCL JOB
String of JCL statements appearing between a proc &
pend statement within a JOB
Available to only one JOB
Up to 15 procedures can be defined within a JOB
Within a JOB, can be invoked any number of times

6
Procedures

Procedures begin with proc or EXEC statements

Only statements allowed in a procedure are EXEC, DD &


comment

Cannot have in stream data statements in a procedure

A procedure cannot invoke another procedure

Cannot contain joblib & job cat DDnames


7
Procedure Statements

Proc statement
Marks the beginning of a procedure
Optional for a cataloged procedure
Required for an in stream procedure; it must appear as the
first control statement in the in stream procedure
Name is optional for cataloged procedures but required for
in stream procedures

8
Rules for Coding Procedures:

1) A procedure name can be one to eight alphanumeric


or national characters. The first character must be
alphabetic or national.

2) No more than 255 job steps cannot be coded in one


procedure

9
PEND statement
Signifies the end of a procedure
Name is optional
eg.
//SORTPROC PROC
//S1 EXEC PGM=SORT
//SORTIN DD DSN=SORTIN.DSN,
DISP=SHR
//SORTOUT DD DSN=SORTOUT.DSN,
// DISP=(NEW,CATLG)
//SORTPROC PEND

10
EXAMPLE
EXAMPLE OF A CATALOGED PROCEDURE
//SORTPROC PROC
//* THIS IS A CATALOGED PROCEDURE
//STEPSORT EXEC PGM=SORT
//SORTIN DD DSN=SORTIN.FILE, DISP=SHR
//SORTOUT DD DSN=SORTOUT.FILE,
// DISP=(,CATLG),UNIT=SYSDA, VOL=SER=VOL001,
// SPACE=(CYL, (10,2)),
// DCB=(LRECL=80, BLKSIZE=80,RECFM=F)
//SORTLIB DD DSN=SYS1.SORTLIB,
// DISP=SHR
//SYSOUT DD SYSOUT=A
//SORTPROC PEND 11
EXAMPLE

To invoke the above procedure:


//SORTJOB JOB (IBM, TRNG), `SORT
PROGRAM’, CLASS = A
//*
//STEP1 EXEC PROC=SORTPROC
//

12
Example

//JOB2 JOB (IBM, TRNG),`INSTREAM


// PROCEXAMPLE’,
// CLASS=A
//* DEFINE THE INSTREAM PROC
//PROC1 PROC
//S1 EXEC PGM=PGM1
//PRODFILE DD
// DSN=PRODUCT.MASTER, DISP=OLD
//REPORT DD SYSOUT=A
//PROC1 PEND

13
Example ( Cont...)

//STEP1 EXEC PGM=UPDATE


//TXN DD DSN=UPDATE.TXN,
// DISP=OLD
//MASTER DD
// DSN=PRODUCT.MASTER,DISP=OLD
//ERROR DD SYSOUT=A
//* INVOKE THE PROC
//STEP2 EXEC PROC=PROC1

14
Symbolic parameters

A symbolic parameter is a symbol preceded


by an ampersand that stands for a
parameter, sub parameter or value

Use it for values that can change with each


execution of the procedure

Makes the procedure more flexible & general purpose

15
Symbolic parameters

Can be 1-7 characters, alphanumeric or national,


preceded by &

A keyword parameter that can be coded on the


EXEC statement like time, cond, parm cannot be
a symbolic parameter

Default values can be specified for a symbolic


parameter in the operand field of the proc
statement

16
Example
//COMPILE PROC &MEM=,&T=1
//* DEFINING THE PROC WITH SYMBOLIC
PARAMETERS
//STEP1 EXEC PGM=IKFCBL00,TIME=&T
//SYSIN DD DSN=IBM.COBOL.SOURCE(&MEM)
//*
//JOB1 JOB
//* INVOKE THE PROC
//S1 EXEC PROC=COMPILE,MEM=PROG01
//* INVOKE THE PROC
//S2 EXEC PROC=COMPILE, MEM=PROG02,T=2

17
Overriding parameters
To override a parameter on the EXEC statement, when invoking the proc, follow on the
proc statement with:
• PARAMETER.PROC STEPNAME=VALUE
EG.
DEFINING THE PROC
//PROC1 PROC
//STEP1 EXEC PGM=PROG01,PARM=`910101’
//DD1 DD DSN=DD1.DSN,DISP=OLD
//*
//STEP2 EXEC PGM=PROG02,PARM=`910101’
//DD2 DD DSN=DD2.DSN,DISP=OLD
INVOKING THE PROC
//JOB1 JOB CLASS=5
//S1 EXEC PROC=PROC1,STEP1.PARM=`910201’
18
Overriding DD statements
Recode the DD statement with the DDnames
proc Stepname.DDnames
No need to recode the entire DD statement.
Just code the changes.
If overriding more than one DD statement,
put the overriding statements in the same
order as they appear in the procedure
To add new DD statements, put them after all the
overriding statements

19
Example

Define the proc

//PROC1 PROC
//STEP1 EXEC PGM=PROG01
//INPUT DD DSN=INPUT.FILE,DISP=OLD
//OUTPUT DD
DSN=OUTPUT.FILE,DISP=(NEW,CATLG),
// UNIT=DISK,VOL=SER=111111,SPACE=(TRK,10),
// DCB=(LRECL=100,BLKSIZE=1000,RECFM=10)

20
Overriding DD statements
Invoke the PROC

//JOB1 JOB
//S1 EXEC PROC=PROC1
//STEP1.INPUT DD*
1234567890
ABCDEFFGHIJKLMNOPQRSTUVWXYZ
/*
//
//JOB1 JOB
//S2 EXEC PROC=PROC01
//STEP1.OUTPUT DD DUMMY,DCB=BLKSIZE=1000
//SYSUDUMP DD SYSOUT=A

21
JCL that executes In-stream Procedure
//TRG034M JOB NOTIFY=&SYSUID,CLASS=A
//*
//***********************************************************************
//* THIS JCL IS AN EXAMPLE FOR INSTREAM PROCEUDRE
//***********************************************************************
//PROC1 PROC
//STEP1 EXEC PGM=IEFBR14
//DD1 DD DSN=TRG034.TRAINING.INSTREAM,
// DISP=(NEW,CATLG,CATLG),
// UNIT=SYSDA,SPACE=(TRK,(1,1),RLSE),
// DCB=(DSORG=PS,LRECL=80,RECFM=FB)
// PEND
//STEP2 EXEC PROC=PROC1

22
JCL to Execute(Run) a Catalog Procedure (this is not a Catalog)

//TRG034M JOB NOTIFY=&SYSUID,CLASS=A


//*
//****************************************************************************
*
//* THIS JCL IS AN EXAMPLE FOR EXECUTING A CATALOG PROCEUDRE

//*U HAVE TO SPECIFY UR CATALOG JCL LIBRARY IN JCLLIB


PARAMETER
//****************************************************************************
*
// JCLLIB ORDER=TRG034.KUMAR.JCL1
//PROC1 EXEC PROC=CATALOG

Note: - Please see the Catalog Procedure in the next slide

23
This is Catalog Procedure
(Cataloged procedures can’t be executed directly, it needs
JCL to run, see the previous slide to run this Catalog
Procedure)
//************************************************
//* THIS JCL IS AN EXAMPLE FOR CATALOG PROCEUDRE

//************************************************
//PROC2 PROC
//STEP1 EXEC PGM=IEFBR14
//DD1 DD DSN=TRG034.TRAINING.CATALOG,
// DISP=(NEW,CATLG,CATLG),
// UNIT=SYSDA,SPACE=(TRK,(1,1),RLSE),
// DCB=(DSORG=PS,LRECL=80,RECFM=FB)
// PEND

24
SYMBOLIC PARAMETERS
//TRG034M JOB NOTIFY=&SYSUID,CLASS=A
//*
//***********************************************************************
//* THIS JCL IS AN EXAMPLE FOR SYMBOLIC PARAMETERS
//* IN INSTREAM PROCEDURE
//***********************************************************************
//PROC1 PROC A=INSTRE
//STEP1 EXEC PGM=IEFBR14
//DD1 DD DSN=TRG034.TRAINING.&A,
// DISP=(NEW,CATLG,CATLG),
// UNIT=SYSDA,SPACE=(TRK,(1,1),RLSE),
// DCB=(DSORG=PS,LRECL=80,RECFM=FB)
// PEND
//STEP2 EXEC PROC=PROC1,A=INSTREAM
Note: Explanation in the next slide

25
//STEP2 EXEC PROC=PROC1,A=INSTREAM
If you provide the value of ‘A’ while executing/running the
Instream procedure then this value will override the
value(default value) that was provided while creating the
proc i.e //PROC1 PROC A=INSTRE

26
Thank You

27

You might also like