You are on page 1of 43

JCL

Day 2

Agenda for Day 2
 DD statement  Syntax  Parameters  Procedures  Types  Symbolic Parameters  Examples  IBM Utility programs  Definition and use  Examples

Copyright © 2005, Infosys Technologies Ltd

2

ER/CORP/CRS/OS02/003 Version No: 1.0

DD STATEMENTS
ddname VOL DCB DSN UNIT DISP SYSMDUMP REFERBACK STEPLIB DD * DATA SYSOUT DUMMY DLM SYSUDUMP SYSABEND JOBLIB

Copyright © 2005, Infosys Technologies Ltd

3

ER/CORP/CRS/OS02/003 Version No: 1.0

DSN
• The name of the data set : 1 to 8 chars

Simple Name

Qualified Name : separated by periods each name 1 to 8 chars total 44 characters including periods

Temporary data sets : &&TEMP or do not mention DSN parameter Refer back : DSN=*.STEP1.DD1
Copyright © 2005, Infosys Technologies Ltd 4 ER/CORP/CRS/OS02/003 Version No: 1.0

DISP

DISP=

NEW OLD SHR MOD

, , , ,

CATLG KEEP UNCATLG DELETE PASS ,

, , , ,

DELETE KEEP CATLG UNCATLG

DISP=(status,normal-disposition,abnormal-disposition)

Copyright © 2005, Infosys Technologies Ltd

5

ER/CORP/CRS/OS02/003 Version No: 1.0

DCB
LRECL=n (VALUE IN BYTES) RECFM=(F/FB/V/VB/U) BLKSIZE= multiple of LRECL DSORG=(PS/PO/DA)

Copyright © 2005, Infosys Technologies Ltd

6

ER/CORP/CRS/OS02/003 Version No: 1.0

SPACE
SPACE=(space units,(primary,secondary,dir),RLSE) space unit - TRK(tracks)/CYL(cylinders)/BLOCKSIZE in bytes EX: SPACE=(TRK,(100,200)) SPACE=(TRK,(10,5)) - allocate 10 tracks primarily and if required as secondary allocation 5 tracks

Copyright © 2005, Infosys Technologies Ltd

7

ER/CORP/CRS/OS02/003 Version No: 1.0

UNIT
Hardware address Type Group

// // // //

UNIT=0320 OR UNIT=3390 OR UNIT=SYSDA OR UNIT=DISK

To use the same unit that has been used by prior DD statement // UNIT=AFF=ddname
Copyright © 2005, Infosys Technologies Ltd 8 ER/CORP/CRS/OS02/003 Version No: 1.0

VOL
It is used to specify a disk volume or specific tapes.

//

VOL=SER=INUSR2,UNIT=SYSDA

To referback a volume used by some prior DD statement use: // VOL=REF=ddname

Copyright © 2005, Infosys Technologies Ltd

9

ER/CORP/CRS/OS02/003 Version No: 1.0

SYSOUT
SYSOUT is used to route output to a device. // DDNAME DD SYSOUT=CLASS // DDNAME DD SYSOUT=A If you want to send the output to the same device described by MSGCLASS of the job use:

// DDNAME DD SYSOUT=*

Copyright © 2005, Infosys 10 Technologies Ltd

ER/CORP/CRS/OS02/003 Version No: 1.0

JOBLIB STATEMENTS
EX //ER5077A JOB ,,CLASS=A //JOBLIB DD DSN=OPERN.CICS3.LOADLIB, // // DISP = (what should be the disposition) DISP = SHR

//STEP1 EXEC PGM=INHOUSE The JOBLIB statement specifies the library (PDS) where the program is residing. It is placed after the JOB statement and is effective for every JOB steps.

Copyright © 2005, Infosys 11 Technologies Ltd

ER/CORP/CRS/OS02/003 Version No: 1.0

STEPLIB STATEMENTS
EX. //STEP1 EXEC PGM=INHOUSE //STEPLIB DD DSN=OPERN.CICS3.LOADLIB, // // DISP = (what should be the disposition) DISP = SHR

The STEPLIB statement defines the library where the program is residing. It is placed after the EXEC statement and is effective for that particular step and overrides any JOBLIB statement.

Copyright © 2005, Infosys 12 Technologies Ltd

ER/CORP/CRS/OS02/003 Version No: 1.0

The first JCL to create a PS.

//ER5077J JOB // //STEP1

1234,ABC,CLASS=A, MSGCLASS=(1,1) TO CREATE PS

EXEC PGM=IEFBR14

//PS1 DD DSN=ER5077.OUTPUT.PSFILE, // UNIT=SYSDA, // VOL=SER=INUSR2, // DCB=(LRECL=80,RECFM=FB,BLKSIZE=800), // SPACE=(TRK,(1,1)),DISP=(NEW,CATLG)

Copyright © 2005, Infosys 13 Technologies Ltd

ER/CORP/CRS/OS02/003 Version No: 1.0

Review Questions
 The positional parameters for an EXEC statement are PGM & PROC  COND Permits the execution of steps to depend on the return code from the Previous Steps  JOBLIB represents the collection of jobs ? False. Represents library for USER programs  JCL has JOBLIB. Step1 has STEPLIB statement. For Step2 the program would be searched in JOBLIB/STEPLIB library? JOBLIB. STEPLIB is valid for only Step1

Copyright © 2005, Infosys 14 Technologies Ltd

ER/CORP/CRS/OS02/003 Version No: 1.0

Review Questions ….
 For the following JCL will Step 2 get executed? //ER5077J JOB ,,NOTIFY=&SYSUID, COND=(4,LT) //STEP1 EXEC PGM=IEFBR14 //STEP2 EXEC PGM=IEFBR14,COND=(0,NE,STEP1) Yes. Step2 would be executed.  If COND parameter is mentioned in JOB & EXEC statement then what happens? COND mentioned in the JOB statement is evaluated first & then the COND mentioned in the EXEC statement

Copyright © 2005, Infosys 15 Technologies Ltd

ER/CORP/CRS/OS02/003 Version No: 1.0

PROCEDURES
 It is a prepacked JCL  A JCL needed by many different users  A JCL executed on a repetitive basis  A JCL often repeated within the execution of a single job

Copyright © 2005, Infosys 16 Technologies Ltd

ER/CORP/CRS/OS02/003 Version No: 1.0

TYPE OF PROCEDURES
 In-stream procedures  Coded in the executing job  Max of 15 per JOB  Catalogued Procedure  Member of a PDS (procedure library)  Max 255 steps

Copyright © 2005, Infosys 17 Technologies Ltd

ER/CORP/CRS/OS02/003 Version No: 1.0

Invoking a Procedure
// EXEC procname // EXEC PROC=procname EX: //name1 EXEC MYPROC //name1 EXEC PROC=MYPROC

Copyright © 2005, Infosys 18 Technologies Ltd

ER/CORP/CRS/OS02/003 Version No: 1.0

PROCEDURES must not contain :
1) 2) 3) 4) 5) 6) 7) JOB statement JOBLIB DD statement DD * , DD DATA - In-stream data /* delimiter statement // Null statement JES statements PEND statement (for cataloged procedures)

Copyright © 2005, Infosys 19 Technologies Ltd

ER/CORP/CRS/OS02/003 Version No: 1.0

In-stream procedure
1. It must begin with a PROC statement and end with a PEND statement 2. It should be coded before the first EXEC statement invoking the instream procedure //ER5077J JOB ,,CLASS=A //PROC1 PROC //STEP2 EXEC PGM=IEFBR14 //DD1 DD DSN=&&TEMP,SPACE=(TRK,(1,1)), // DCB=(RECFM=FB,BLKSIZE=800,LRECL=80), // DISP=(NEW,KEEP),UNIT=SYSDA // PEND //STEP1 EXEC PROC1 //

Copyright © 2005, Infosys 20 Technologies Ltd

ER/CORP/CRS/OS02/003 Version No: 1.0

CATALOGED PROCEDURE
1. 2. 3. 4. It must be a member of PDS PEND statement is not mandatory It can have a maximum of 255 steps The name of the library (PDS) should be specified if cataloged library is not in the system defined library (SYS1.PROCLIB) using JES JOBPARM statement or JCLLIB statement

Copyright © 2005, Infosys 21 Technologies Ltd

ER/CORP/CRS/OS02/003 Version No: 1.0

JCLLIB
Specifies the names of the private libraries the system has to search for: a) Procedures named on any EXEC statement b) JCL referenced by the INCLUDE statement (after release 4) ex: // INCLUDE MEMBER=MYJCL

The JCLLIB statement must be placed before the first EXEC statement in the job // JCLLIB ORDER=(library[,library]....) // JCLLIB ORDER=(MYPROC.JCL.PROCLIB, // MYPROC.JCL.PROCLIB1)

Copyright © 2005, Infosys 22 Technologies Ltd

ER/CORP/CRS/OS02/003 Version No: 1.0

Cataloged procedure
It must begin with a PROC statement and PEND is optional. It must be cataloged in order to access it that is it must be a member of a PDS. Cataloged procedure : //MYPROC PROC //STEP2 EXEC PGM=IEFBR14 //DD1 DD DSN=&&TEMP,SPACE1(TRK,(1,1)), // DCB=(RECFM=FB,BLKSIZE=800,LRECL=80), // DISP=(NEW,KEEP),UNIT=SYSDA • Cataloged procedure called through a JCL : //ER5077J JOB ,ABC, CLASS=A // JCLLIB ORDER=(ER5077.PROCLIB) //STEP1 EXEC MYPROC
Copyright © 2005, Infosys 23 Technologies Ltd ER/CORP/CRS/OS02/003 Version No: 1.0

Questions ??
If a JCL has two procedures, an instream procedure first and a cataloged procedure next with the same name, which one will be executed ? //ER5077J //JCLLIB //MYPROC //STEP1 //DD1 JOB ,,NOTIFY=&SYSUID,CLASS=A ORDER=(ER4857.PROCLIB) PROC EXEC PGM=IEFBR14 DD DSN=ER5077.TEST.CAT,SPACE=(TRK,(1,1)),

// DCB=(RECFM=FB,BLKSIZE=800,LRECL=80), // DISP=(NEW,DELETE),UNIT=SYSDA // PEND //STEP1 EXEC MYPROC //* Answer : The Instream procedure will be executed
Copyright © 2005, Infosys 24 Technologies Ltd ER/CORP/CRS/OS02/003 Version No: 1.0

Questions ??
If a JCL has two procedures, a cataloged procedure first and an instream procedure next with the same name which one will be executed ? //ER5077J JOB ,,NOTIFY=&SYSUID,CLASS=A // JCLLIB ORDER=(ER5077.PROCLIB) //STEP1 EXEC MYPROC //MYPROC PROC //STEP1 EXEC PGM=IEFBR14 //DD1 DD DSN=ER5077.TEST.CAT,SPACE=(TRK,(1,1)), // DCB=(RECFM=FB,BLKSIZE=800,LRECL=80), // DISP=(NEW,DELETE),UNIT=SYSDA // PEND //* Answer : Cataloged procedure will be executed
Copyright © 2005, Infosys 25 Technologies Ltd ER/CORP/CRS/OS02/003 Version No: 1.0

Nested Procedures
 Cataloged and In-stream procedure can invoke other procedure ( up to 15 level)

 An In-stream procedure cannot be defined within another procedure

Copyright © 2005, Infosys 26 Technologies Ltd

ER/CORP/CRS/OS02/003 Version No: 1.0

Nested Procedures (examples)
//ER5077J JOB ,,NOTIFY=ER4857,CLASS=A //LIB1 JCLLIB ORDER=(ER5077.JCL.SOURCE) //FSTPROC PROC //STEP1 EXEC MYPROC // PEND //SNDPROC PROC //STEP1 EXEC FSTPROC // PEND //STEP1 EXEC SNDPROC //* • SNDPROC is called first which calls FSTPROC which initiates cataloged procedure MYPROC

Copyright © 2005, Infosys 27 Technologies Ltd

ER/CORP/CRS/OS02/003 Version No: 1.0

Nested Procedures
• NSTPROC //NSTPROC PROC //STEP1 EXEC PGM=IEFBR14 • MYPROC //MYPROC PROC //STEP1 EXEC NESTPROC //STEP2 EXEC PGM=IEFBR14,COND=(0,NE) //DD1 DD DSN=&&TEMP,SPACE=(TRK,(1,1)), // DCB=(RECFM=FB,BLKSIZE=800,LRECL=80), // VOL=SER=INUSR3, // DISP=(NEW,KEEP),UNIT=SYSDA • CALLJCL //ER5077J JOB ,,NOTIFY=&SYSUID,CLASS=A // JCLLIB ORDER=(ER5077.PROCLIB) //STEP1 EXEC MYPROC
Copyright © 2005, Infosys 28 Technologies Ltd ER/CORP/CRS/OS02/003 Version No: 1.0

Modifying the Procedure
SYMBOLIC PARAMETERS OVERRIDING EXEC & DD PARAMETERS

Copyright © 2005, Infosys 29 Technologies Ltd

ER/CORP/CRS/OS02/003 Version No: 1.0

Symbolic Parameters
Symbolic parameters are variables used in procedures Syntax - &Varname Varname - 1-7 character

Value can be specified at : 1) SET statement 2) EXEC PROC statement 3) PROC statement

Copyright © 2005, Infosys 30 Technologies Ltd

ER/CORP/CRS/OS02/003 Version No: 1.0

Symbolic Parameters examples ...

//ER5077J JOB ,,CLASS=A //SET1 SET A=ER5077.PDS.SAMPLE //STEP1 EXEC PGM=IEFBR14 //DD1 DD DSN=&A,SPACE=(TRK,(1,1)), // DCB=(RECFM=FB,BLKSIZE=800,LRECL=80), // DISP=(NEW,DELETE),UNIT=SYSDA

Copyright © 2005, Infosys 31 Technologies Ltd

ER/CORP/CRS/OS02/003 Version No: 1.0

Symbolic Parameters examples ...

//ER5077J JOB ,, CLASS=A //MYPROC PROC A=ER5077.PDS.SAMPLE //STEP2 EXEC PGM=IEFBR14 //DD1 DD DSN=&A,SPACE=(TRK,(1,1)), // DCB=(RECFM=FB,BLKSIZE=800,LRECL=80), // DISP=(NEW,DELETE),UNIT=SYSDA // PEND //STEP1 EXEC MYPROC

Copyright © 2005, Infosys 32 Technologies Ltd

ER/CORP/CRS/OS02/003 Version No: 1.0

REFERING BACK

//ER5077J JOB ,,NOTIFY=&SYSUID,CLASS=A //STEP1 EXEC PGM=IEFBR14 //DD1 DD DSN=ER5077.TEST.PS1,SPACE=(TRK,(1,1)), // // //DD2 // // DCB=(RECFM=FB,BLKSIZE=800,LRECL=80), DISP=(NEW,DELETE),UNIT=SYSDA DD DSN=ER5077.TEST.PS2,SPACE=(TRK,(1,1)), DCB=*.DD1,VOL=SER=INUSR3, DISP=(NEW,DELETE),UNIT=SYSDA

Copyright © 2005, Infosys 33 Technologies Ltd

ER/CORP/CRS/OS02/003 Version No: 1.0

REFERING BACK

//ER5077J JOB ,ABC,NOTIFY=&SYSUID,CLASS=A //STEP1 EXEC PGM=IEFBR14 //DD1 DD DSN=ER5077.TEST.PS1,SPACE=(TRK,(1,1)), // DCB=(RECFM=FB,BLKSIZE=800,LRECL=80), // DISP=(NEW,CATLG),UNIT=SYSDA //STEP2 EXEC PGM=IEFBR14 //DD1 DD DSN=*.STEP1.DD1,SPACE=(TRK,(1,1)), // DCB=*.STEP1.DD1,VOL=SER=INUSR3, // DISP=(OLD,DELETE),UNIT=SYSDA

Copyright © 2005, Infosys 34 Technologies Ltd

ER/CORP/CRS/OS02/003 Version No: 1.0

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.

Provides a variety of useful function like  Copying a member/data set  Listing  Maintaining source libraries etc.

Copyright © 2005, Infosys 35 Technologies Ltd

ER/CORP/CRS/OS02/003 Version No: 1.0

UTILITY PROGRAMS
• • • • • • SYSTEM UTILITY IEHLIST IEHMOVE IEHINITT IEHPROGM IFHSTATR • • • • • • • • • DATA SET UTILITY IEBGENER IEBCOPY IEBCOMPR IEBPTPCH IEBDG IEBUPDTE IEBMOVE IEBEDIT

• •

IDCAMS IEFBR14

Copyright © 2005, Infosys 36 Technologies Ltd

ER/CORP/CRS/OS02/003 Version No: 1.0

GENERAL FORMAT FOR IEBXXXX

//STEP

EXEC PGM=IEBxxxx

//SYSPRINT DD (message data set ,no DCB) //SYSIN //SYSUT1 //SYSUT2 DD (Control information for utility) DD (input data set) DD (output dataset)

Copyright © 2005, Infosys 37 Technologies Ltd

ER/CORP/CRS/OS02/003 Version No: 1.0

IEBGENER utility
• It is used to copy one sequential file to another. //ER5077J JOB ,ABC,CLASS=A,NOTIFY=&SYSUID //STEP1 EXEC PGM=IEBGENER //SYSPRINT DD SYSOUT=* //SYSUT2 DD DSN=ER5077.IEBGENER.NEWPS, // VOL=SER=INUSR2,SPACE=(TRK,(1,1)), // DCB=(RECFM=FB,LRECL=80,BLKSIZE=800), // DISP=(NEW,CATLG) //SYSUT1 DD DSN=ER5077.INPUT.JCLPS1,DISP=SHR //SYSIN DD DUMMY

Copyright © 2005, Infosys 38 Technologies Ltd

ER/CORP/CRS/OS02/003 Version No: 1.0

IEBCOPY
• • To copy PDS on to DASD To copy PDS on to Tapes by converting it to sequential dataset etc

//ER5077J JOB ,,CLASS=A,NOTIFY=ER5077 //STEP1 EXEC PGM=IEBCOPY //SYSPRINT DD SYSOUT=A //SYSUT1 DD DSN=ER5077.JCL.SOURCE,DISP=SHR //SYSUT2 DD DSN=ER5077.IEBCOPY.PDS, // VOL=SER=INUSR2,SPACE=(TRK,(5,5,8)), // DCB=(RECFM=FB,LRECL=80,BLKSIZE=800), // DISP=(NEW,CATLG) //SYSIN DD * COPY INDD=SYSUT1,OUTDD=SYSUT2 /*
Copyright © 2005, Infosys 39 Technologies Ltd ER/CORP/CRS/OS02/003 Version No: 1.0

IEFBR14
• Using IEFBR14 you can create empty data sets or delete data sets

Allocate new flat files //ER5077J JOB ,,CLASS=A,NOTIFY=&SYSUID //STEP1 EXEC PGM=IEFBR14, //DD1 DD DSN=ER5077.JCL.PS,DISP=(NEW,CATLG,DELETE), // UNIT=SYSDA, SPACE=(CYL(2,2),RLSE), // DCB=(LRECL=80,BLKSIZE=0,RECFM=FB) //SYSPRINT DD SYSOUT=*

Copyright © 2005, Infosys 40 Technologies Ltd

ER/CORP/CRS/OS02/003 Version No: 1.0

SORT
• • This can be used to sort, copy, merge data sets To SORT records in a dataset in ascending/descending order on given field(s) //STEP1 EXEC PGM=SORT //SYSPRINT DD SYSOUT=* //SORTIN DD DSN=input data set,DISP=SHR //SORTOUT DD DSN=output data set, // DISP=(,CATLG), // DCB=*.SORTIN, // SPACE=(CYLS,(10,10),RLSE) //* //************* //* SORT CARD : //************* //SYSIN DD * SORT FIELDS=(1,05,CH,A), //*

Copyright © 2005, Infosys 41 Technologies Ltd

ER/CORP/CRS/OS02/003 Version No: 1.0

Review Questions
 Instream procedure could be member of a PDS? NO  A Catalogued procedure can call an Instream procedure? NO  Which type of parameters are used to customize the procedure? Symbolic  Catalogued procedure can invoke other procedures beyond 20 levels? No. Till 15 Levels.

Copyright © 2005, Infosys 42 Technologies Ltd

ER/CORP/CRS/OS02/003 Version No: 1.0

Thank You!
Copyright © 2005, Infosys 43 Technologies Ltd ER/CORP/CRS/OS02/003 Version No: 1.0