Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 29

JCL

Session 3
Procedures…
 Procedures are pre-packed JCLs used when:
◦ Same JCL is needed by many different users
◦ A JCL has to be executed on a repetitive basis
◦ JCL statements often repeated within the execution of a single job

Types
 In-stream
◦ Coded in the executing job
◦ Maximum of 15 per JCL
 Catalogued
◦ Separate member in a procedure library PDS
◦ Maximum of 255 steps per PROC

© Strictly confidential 2
…Procedures
 Invoked by using the EXEC statement in a JCL
 Example:

//STEP04 EXEC PROC=MYPROC1


 Keyword PROC is optional
 Called PROC can be in-stream or catalogued
 Alternate way of invoking procedure

//STEP04 EXEC MYPROC1

© Strictly confidential 3
JCLLIB…
 Specifies the names of the private libraries the system is to search for
◦ Catalogued procedures named on any EXEC statement in a JCL
◦ JCL referenced by the INCLUDE statement (after MVS / ESA
release 4)
 The JCLLIB statement must be placed before the first EXEC
statement in the job
 Format:

//[name] JCLLIB ORDER=(data set 1[,data set 2]....)


◦ name is optional
◦ At least one data set must be specified
◦ All data set names to be fully qualified, without quotes
 Example:

//MYPROCS JCLLIB ORDER=(TEST01.JCL.PROCLIB1,


// TEST01.JCL.PROCLIB2)

© Strictly confidential 4
…JCLLIB
 After the private data sets specified in JCLLIB are searched for
PROCs, system data set SYS1.PROCLIB is searched
 SYS1.PROCLIB contains system-oriented cataloged procedures, like
those supplied by IBM
 SYS1.PROCLIB can also be used to store other types of cataloged
procedures (like those for production jobs, job steps etc.)
 The following is the order in which PROCs are searched for:
◦ JCLLIB data sets (in the same order in which they are specified)
◦ System data sets

© Strictly confidential 5
Contents of procedures
Unlike JCLs, PROCs cannot contain:
 JOB statement
 In-stream data
 /* delimiter statement
 // statement
 JES statements

PROCs can contain:


 PROC statement to indicate start of the PROC
 Calls to other PROCs (up to 15 levels)

PROCs cannot contain:


 Definitions of other PROCs

© Strictly confidential 6
In-stream procedures
 Must begin with a PROC statement and end with a PEND statement
 Should be coded before the first EXEC statement invoking the in-
stream procedure
 Example:

//TEST01C JOB (TEST PROC),NOTIFY=TEST01,CLASS=A


//PROC1 PROC
//PSTEP1 EXEC PGM=IEFBR14
//DD1 DD DSN=&&TEMP,SPACE=(TRK,(1,1)),
//
DCB=(RECFM=FB,BLKSIZE=800,LRECL=80),VOL=SER=TSTV
OL1,
// DISP=(NEW,KEEP),UNIT=SYSDA
// PEND
//STEP1 EXEC PROC1
 Name is optional on the PEND statement
© Strictly confidential 7
Catalogued procedures
 Must begin with a PROC statement
 Must NOT contain a PEND statement
 Must be a member of a PDS, referred to in the JCLLIB or catalogued
at the system level
 Example – PROC:

//PROC1 PROC
//PSTEP1 EXEC PGM=IEFBR14
//DD1 DD DSN=&&TEMP,SPACE=(TRK,(1,1)),
//
DCB=(RECFM=FB,BLKSIZE=800,LRECL=80),VOL=SER=TSTV
OL1,
// DISP=(NEW,KEEP),UNIT=SYSDA
 Example – JCL calling the PROC

//TEST01C JOB (TEST PROC),NOTIFY=TEST01,CLASS=A


// JCLLIB ORDER=(TEST01.TEST.PROCLIB)
//STEP1 EXEC PROC1 © Strictly confidential 8
In-stream versus catalogued procedures
 If an in-stream and a catalogued procedure have the same name and
that PROC is called in the JCL, the following is the order of
precedence:
◦ If the in-stream PROC is coded before the EXEC call, then it is
called
◦ If the in-stream PROC is coded after the EXEC call, then that
catalogued PROC is called

© Strictly confidential 9
Symbolic parameters in PROCs…
 Variables used in procedures
 Usually used to override parameters in the PROC from the JCL
 Values are passed from JCL to PROC through:

◦ EXEC PROC statement


◦ SET statement
 Format:

&varname
◦ varname is1 to 7 characters long
 & is used for the varname only in the PROC
 When supplying value to varname in the JCL, & is not used

© Strictly confidential 10
Rules for symbolic parameters…
 You can use the same symbolic parameter in a procedure as many
times as you wish
 Symbolic parameters can be mixed with text to form a final parameter
value
 If you want text to appear immediately after a symbolic parameter,
you must code a period as a delimiter between the symbolic parameter
name and the text that follows it
 If you want a period to appear immediately after a symbolic
parameter, you have to code two periods in a row. The first one acts as
a delimiter marking the end of the symbolic parameter and the second
one becomes part of the JCL statement
 To nullify the value of a symbolic parameter, you code the symbolic
parameter’s name followed by an equals sign without a value

© Strictly confidential 11
…Rules for symbolic parameters
Example
 Variables VAR1 and VAR2 are in the PROC
 The following JCL snippet executes the PROC by passing values to
the variables:
//STEP04A EXEC proc-name,VAR1=TEST,VAR2=LIST

Code in PROC As interpreted by JES


DSN=&VAR1 DSN=TEST
DSN=A&VAR1 DSN=ATEST
DSN=&VAR1(&VAR2) DSN=TEST(LIST)
DSN=&VAR1.A DSN=TESTA
DSN=&VAR1..A DSN=TEST.A
DSN=&VAR1&VAR2 DSN=TESTLIST
DSN=&VAR1..&VAR2 DSN=TEST.LIST

© Strictly confidential 12
…Symbolic parameters in PROCs…
Passing data set name from JCL to PROC through EXEC PROC
 Example – PROC

//TESTPROC PROC
//PRCSTEP1 EXEC PGM=IEFBR14
//DD1 DD DSN=&DSN1,SPACE=(TRK,(1,1)),
// DCB=(RECFM=FB,BLKSIZE=800,LRECL=80),
// VOL=SER=TSTVOL1,
// DISP=(NEW,DELETE),UNIT=SYSDA
 Example – JCL snippet

//STEP01 EXEC TESTPROC,DSN1=TEST01.TEST.PS

© Strictly confidential 13
…Symbolic parameters in PROCs…
Passing part of data set name from JCL to PROC through EXEC PROC
 Example – PROC

//TESTPROC PROC
//PRCSTEP1 EXEC PGM=IEFBR14
//DD1 DD DSN=&QUAL1..TEST.DATASET,
// SPACE=(TRK,(1,1)),
// DCB=(RECFM=FB,BLKSIZE=800,LRECL=80),
// VOL=SER=TSTVOL1,
// DISP=(NEW,DELETE),UNIT=SYSDA
 Example – JCL snippet

//STEP01 EXEC TESTPROC,QUAL1=TEST01


 Note the two periods after the variable name in the PROC. This is
because the end of the variable is indicated by a period, as the next
character happens to be a period

© Strictly confidential 14
…Symbolic parameters in PROCs…
Passing other parameters from JCL to PROC through EXEC PROC
 Example – PROC

//TESTPROC PROC
//PRCSTEP1 EXEC PGM=MYPROG
//DD1 DD DSN=TEST01.TEST.PS1, DISP=SHR
//SYSOUT DD SYSOUT=&CLS
 Example – JCL snippet

//STEP01 EXEC TESTPROC,CLS=M

© Strictly confidential 15
…Symbolic parameters in PROCs…
Passing sub-parameters from JCL to PROC through EXEC PROC
 Example – PROC

//TESTPROC PROC
//PRCSTEP1 EXEC PGM=IEFBR14
//DD1 DD DSN=TEST01.TEST.PS,SPACE=(TRK,(&SPC)),

// DCB=(RECFM=FB,BLKSIZE=800,LRECL=80),
// VOL=SER=TSTVOL1,
// DISP=(NEW,DELETE),UNIT=SYSDA
 Example – JCL snippet

//STEP01 EXEC TESTPROC,SPC=‘3,1’

© Strictly confidential 16
…Symbolic parameters in PROCs
Passing parameters and sub-parameters from JCL to PROC through SET
 Example – PROC

//TESTPROC PROC
//PRCSTEP1 EXEC PGM=IEFBR14
//DD1 DD DSN=&DSN1,SPACE=(TRK,(&SPC)),
// DCB=(RECFM=FB,BLKSIZE=800,LRECL=80),
// VOL=SER=TSTVOL1,
// DISP=(NEW,DELETE),UNIT=SYSDA
 Example – JCL snippet

//TEST01B JOB 1234,(TEST JCL),NOTIFY=TEST01,CLASS=A


// SET DSN1=TEST01.TRY.PS
// SET SPC=‘3,1’
//STEP01 EXEC TESTPROC

© Strictly confidential 17
Overriding DDs in PROCs
 In addition to using symbolic parameters, it is also possible to
override the complete DD used in PROC through the JCL
 Example – PROC

//TESTPROC PROC
//PRCSTEP1 EXEC PGM=IEFBR14
//DD1 DD DSN=TEST01.TRY.PS,DISP=SHR
 Example – JCL snippet

//STEP01 EXEC TESTPROC


//PRCSTEP1.DD1 DD DSN=TEST01.ANOTHER.PS,DISP=SHR

© Strictly confidential 18
Modifying EXEC statements in PROCs…
 To change a parameter that’s coded on an EXEC statement within a
procedure or to add a parameter to one of the procedure’s EXEC
statements, you code a parameter override on the EXEC statement
that invokes the procedure
 If you want to override more than one parameter, you separate the
parameter overrides with commas
 Because it’s necessary to associate parameters with procedure step
names, it’s important that each step in a procedure has a unique name
 The functions of parameter overrides in an invoking EXEC statement:
◦ Modify the existing parameters on an EXEC statement within a
procedure
◦ Add parameters to an EXEC statement within a procedure
◦ Add parameters to all EXEC statements within a procedure
◦ Nullify the effects of a parameter on an EXEC statement within a
procedure

© Strictly confidential 19
…Modifying EXEC statements in PROCs…
 Example – PROC
//TESTPROC PROC
//PRCSTEP1 EXEC PGM=TESTPROG,PARM=(5,6)
//INPDD DD DSN=TEST01.TEST.PS,DISP=SHR
//PRCSTEP2 EXEC PGM=SOMEPROG,PARM=(2,2)

 Example – JCL snippet


//STEP01 EXEC TESTPROC,PARM.PRCSTEP1=(1,2)
 JCL passes PARM values of 1 and 2 to program TESTPROG instead
of 5 and 6 in the PROC
 It is mandatory to indicate the step name of the PROC in the JCL for
this override, as the PROC contains other steps and the JCL needs to
specify clearly as to which step it is overriding

© Strictly confidential 20
…Modifying EXEC statements in PROCs
 Example – PROC
//TESTPROC PROC
//PRCSTEP5 EXEC PGM=TESTPROG,TIME=(15,0)
 Example – JCL snippet

//STEP01 EXEC TESTPROC,TIME.PRCSTEP5=(20,30)


 JCL overrides TIME parameter in the PROC for PRCSTEP5
 Again, it is mandatory to indicate the step name of the PROC in the
JCL for this override

© Strictly confidential 21
IBM utility programs…
 MVS provides a number of pre-written utility programs that can be
used by analysts, system programmers, and application programmers
to assist them in maintaining and organizing data
 These utility programs provide a variety of useful functions like
◦ Copying a PDS member / data set
◦ Listing data sets
◦ Maintaining source libraries
 Utility programs are either of the following
◦ System utilities
◦ Data set utilities

© Strictly confidential 22
…IBM utility programs
Some system utility programs
 IEHATLAS
 IEHINITT
 IEHMOVE
 IEHPROGM
 IFHSTATR

Some data set utility programs


 IEBCOMPR
 IEBCOPY
 IEBDG
 IEBEDIT
 IEBGENER
 IEBISAM
© Strictly confidential 23
Format for calling IBM utility programs
 JCL / PROC snippet
//STEP EXEC PGM=IEBxxxx
//SYSPRINT DD message data set; no DCB
//SYSIN DD control information for utility
//SYSUT1 DD input data set
//SYSUT2 DD output dataset

© Strictly confidential 24
IEBGENER utility
 Used to copy one sequential file to another
//TEST01B JOB CLASS=A,NOTIFY=TEST01
//STEP1 EXEC PGM=IEBGENER
//SYSPRINT DD SYSOUT=*
//SYSUT1 DD DSN=TEST01.INPUT.PS,DISP=SHR
//SYSUT2 DD DSN=TEST01.IEBGENER.NEWPS,
// VOL=SER=TSTVOL1,SPACE=(TRK,(1,1)),
// DCB=(RECFM=FB,LRECL=80,BLKSIZE=800),
// DISP=(NEW,CATLG)
//SYSIN DD DUMMY

© Strictly confidential 25
IEBCOPY utility
 Used to copy PDS to DASD
 Used to copy PDS to a tape by converting it to sequential dataset
//TEST01B JOB CLASS=A,NOTIFY=TEST01
//STEP1 EXEC PGM=IEBCOPY
//SYSPRINT DD SYSOUT=A
//SYSUT1 DD DSN=TEST01.JCL.SOURCE,DISP=SHR
//SYSUT2 DD DSN=TEST01.IEBCOPY.PDS,
// VOL=SER=TSTVOL2,SPACE=(TRK,(5,5,8)),
// DCB=(RECFM=FB,LRECL=80,BLKSIZE=800),
// DISP=(NEW,CATLG)
//SYSIN DD *
COPY INDD=SYSUT1,OUTDD=SYSUT2
/*

© Strictly confidential 26
IDCAMS utility
 Used to print or copy or delete or allocate data sets
//TEST01B JOB CLASS=A,NOTIFY=TEST01
//STEP1 EXEC PGM=IDCAMS
//SYSPRINT DD SYSOUT=*
//INFILE DD DSN=TEST01.DATA.PS,DISP=SHR
//SYSIN DD *
PRINT INFILE(INFILE) CHARACTER
/*

© Strictly confidential 27
IEHPROGM utility
 Used for doing the following to data sets:
◦ Scratch
◦ Rename
◦ Catalog
◦ Uncatalog
 Utility control statements
SCRATCH DSNAME=dsname,VOL=device=serial
UNCATLG DSNAME=dsname

© Strictly confidential 28
IEHLIST utility
 Used to list either of the following:
◦ Catalog
◦ PDS
◦ VTOC
 Utility control statements
LISTPDS DSNAME=dsname, x
VOL=device=serial,format
LISTVTOC DSNAME=dsname, x
VOL=device=serial,format
 x indicates that control statement is continuing in the next line

© Strictly confidential 29

You might also like