JCL - Session03 1
JCL - Session03 1
JCL - Session03 1
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:
© 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:
© 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
© 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:
//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
© 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:
&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
© 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
© 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
© 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
© 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
© 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
© 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
© 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)
© Strictly confidential 20
…Modifying EXEC statements in PROCs
Example – PROC
//TESTPROC PROC
//PRCSTEP5 EXEC PGM=TESTPROG,TIME=(15,0)
Example – JCL snippet
© 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
© 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