0% found this document useful (0 votes)
4 views26 pages

JCL Session02

Uploaded by

Nagamani
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views26 pages

JCL Session02

Uploaded by

Nagamani
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 26

JCL

Session 2
COND statement…
 Condition statement to execute a step based on return codes from
previous steps
 Can also be used at job level. Indicates condition in which job should
abend, based on return code from any step in the job
 Format:
COND=(return code,operator,step name,EVEN/ONLY)
 step name and EVEN/ONLY are used only in steps, not at job level
Field Description

return code Comparison values for return codes. Can be from 0 to 4095

operator Logical operator. Can take values of GT, GE, LT, LE, EQ, NE
step name Name of previous step whose return code is being checked
EVEN – Current step will be executed even if previous steps
EVEN/ abend
ONLY ONLY – Current step will be executed only if previous steps
abend
© Strictly confidential 2
…COND statement…
Job level
 If condition given at job level is satisfied by return code from any
step, then the job abends at that step and does not proceed further
 Example:
//TEST01C JOB 1234,(TEST JCL),COND=(8,LE)
//STEP01 EXEC PGM=MYPROG

//STEP02 EXEC PROC1

//STEP03 EXEC PGM=YOURPROG

 If 8 is less than or equal to return code from STEP01 or STEP02 or
STEP03, then the job abends in that step
 That is, job abends if RC from any step is 8 or more

© Strictly confidential 3
…COND statement…
Step level…
 Condition actually specifies ‘skip’. That is, if given in a step, it
indicates that this step be skipped if the particular condition is
satisfied
 Example:
//TEST01C JOB 1234,(TEST JCL)
//STEP01 EXEC PGM=MYPROG

//STEP02 EXEC PROC1,COND=(4,LT,STEP01)

//STEP03 EXEC PGM=YOURPROG

 If 4 is less than return code of STEP01, then STEP02 is skipped
 That is, STEP02 is skipped if STEP01’s return code is more than 4
 STEP02 is executed if STEP01 returns 4 or less
© Strictly confidential 4
…COND statement…
…Step level…
 If no COND is specified in the JCL, then if a step abends (that is,
return code of 8 or more), the job abends (that is, no further steps are
executed)
 Return code 4 is only a warning, not an abend
 ONLY – Current step will be executed only if previous steps abend
 Example:
//TEST01C JOB 1234,(TEST JCL)
//STEP01 EXEC PGM=MYPROG
//STEP02 EXEC PROC1,COND=ONLY
//STEP03 EXEC PGM=YOURPROG

STEP0
RC 0 or 4 RC 8 or more RC 8 or more
1
STEP0
Skipped Executed with RC 0 or 4 Executed with RC 8 or more
2
STEP0 Skipped due to RC of Skipped due to RCs of
Executed
3 STEP01 © Strictly confidential STEP01 and STEP02 5
…COND statement…
…Step level…
 EVEN – Current step will be executed even if previous steps abend
 Example:
//TEST01C JOB 1234,(TEST JCL)
//STEP01 EXEC PGM=MYPROG
//STEP02 EXEC PROC1,COND=EVEN
//STEP03 EXEC PGM=YOURPROG

STEP0
RC 0 or 4 RC 8 or more RC 8 or more
1
STEP0 Executed with RC 0 Executed with RC 0 Executed with RC 8 or
2 or 4 or 4 more
STEP0 Skipped due to RC of Skipped due to RCs of
Executed
3 STEP01 STEP01 and STEP02

© Strictly confidential 6
…COND statement…
…Step level…
 And condition is possible with multiple sub-parameters
 Example:
//TEST01C JOB 1234,(TEST JCL)
//STEP01 EXEC PGM=MYPROG
//STEP02 EXEC PROC1
//STEP03 EXEC PGM=YOURPROG, COND=((0,NE,STEP02),ONLY)

STEP0
RC 0 or 4 RC 0 or 4 RC 0 or 4 RC 8 or more
1
STEP0 Executed Executed with RC Executed with
Skipped
2 with RC 0 4 RC 8 or more
Skipped due to Skipped as no
STEP0 Skipped due Skipped due to
RC of STEP02 RC from
3 to ONLY RC of STEP02
and ONLY STEP02

© Strictly confidential 7
…COND statement…
…Step level
 Example:
//TEST01C JOB 1234,(TEST JCL)
//STEP01 EXEC PGM=MYPROG
//STEP02 EXEC PROC1
//STEP03 EXEC PGM=YOURPROG,
// COND=((0,NE,STEP02),(0,NE,STEP01))

STEP0
RC 0 RC 0 RC 4 RC 8 or more
1
STEP0 Executed Executed with RC Executed with
Skipped
2 with RC 0 4 or more RC 4 or more
Skipped due to
STEP0 Skipped due to Skipped due to
Executed RC of STEP01
3 RC of STEP02 RC of STEP01
and STEP02

© Strictly confidential 8
…COND statement
Step level overriding job level
 Example:
//TEST01C JOB 1234,(TEST JCL),COND=(0,NE)
//STEP01 EXEC PGM=MYPROG
//STEP02 EXEC PROC1
//STEP03 EXEC PGM=YOURPROG,COND=(0,EQ,STEP02)

STEP0
RC 0 RC 0 RC 4 or more RC 8 or more
1
STEP0 Executed Executed with RC Skipped due to Skipped due to
2 with RC 0 4 or more JOB COND JOB COND
Skipped due Skipped due to
STEP0 Skipped due to
to STEP Executed RC of STEP01
3 RC of STEP01
COND and STEP02

© Strictly confidential 9
IF/THEN/ELSE/ENDIF statement…
 Available in MVS / ESA release 4 or later
 Makes it easier to code conditions and makes JCL more readable
 Format:
//name IF (stepname.RC relationaloperator value) THEN
JCL statements
// ELSE
JCL statements
// ENDIF

Field Description
Optional name. If given, should not repeat in a JCL. If not
name
given, column 3 should be blank
stepname Name of the step whose return code is being referred to
relationaloperat
Same as COND; GT, GE, LT, LE, EQ, NE
or
value Same as COND; can take any value from 0 to 4095
© Strictly confidential 10
…IF/THEN/ELSE/ENDIF statement…
 Nested IFs are possible, up to 15 levels
 Multiple conditions are possible within brackets, with AND (or &),
OR (or |) and NOT (or ¬) allowed
 Example:
//STEP01 EXEC PGM=TESTPGM
// IF (STEP01.RC LT 4) THEN
//STEP02 EXEC PROC=PROC1
// ELSE
//STEP03 EXEC PROC=PROC2
// ENDIF
STEP01 RC 0 RC 4 or more
STEP02 Executed Skipped
STEP03 Skipped Executed

© Strictly confidential 11
…IF/THEN/ELSE/ENDIF statement
 Example:
//STEP01 EXEC PGM=TESTPGM1
//STEP02 EXEC PGM=TESTPGM2
// IF ((STEP01.RC LE 4) AND (STEP02.RC LT 4)) THEN
//STEP03 EXEC PROC=PROC1
// ELSE
//STEP04 EXEC PROC=PROC2
// ENDIF

STEP01 RC 0 or 4 RC 0 or 4 RC 8 or more
STEP02 RC 0 RC 4 or more Skipped
STEP03 Executed Skipped Skipped
STEP04 Skipped Executed Skipped

© Strictly confidential 12
DD statement…
//INPDD DD DSN=TEST01.TRY.PS, DISP=(NEW,CATLG),
// UNIT=SYSDA,VOL=SER=TST01R,
// DCB=(LRECL=80,RECFM=FB,BLKSIZE=800),
// SPACE=(TRK,(1,1))
 INPDD is the logical name of the data set
 DD is the mandatory keyword, indicating that this is a DD statement
 All parameters are keyword parameters

DSN= parameter
 Indicates that the Data Set Name is being given
 Is followed by the name of the physical data set (TEST01.TRY.PS)
 For temporary data sets, give a name of not more than 8 characters,
prefixed by &&. These are used within a job and are not available
once the job ends

© Strictly confidential 13
…DD statement…
//INPDD DD DSN=TEST01.TRY.PS, DISP=(NEW,CATLG),…

DISP parameter…
 Has 3 optional sub-parameters, each separated by comma

Sub-
Description Values
parameter
NEW – Data set to be created in this step
Status of the SHR – Data set is shared (i.e.) other jobs can
data set at the use it at the same time
Initial status
beginning of OLD – Data set is opened exclusively
the step MOD – Data will be appended to data set;
data set will be created if it does not exist

© Strictly confidential 14
…DD statement…
//INPDD DD DSN=TEST01.TRY.PS, DISP=(NEW,CATLG),…

…DISP parameter…

Sub-
Description Values
parameter
KEEP – Data set is to be kept
DELETE – Data set is to be deleted
Disposition of
PASS – Data set is to be passed to a
Normal the data set
subsequent step in the JCL
termination when the job
CATLG – Data set is to be kept and place an
status terminates
entry in the system or user catalog
normally
UNCATLG – Delete the entry in the system
or user catalog; data set is kept
Disposition of
Abnormal the data set
Same as above, except that PASS is not
termination when the job
available
status terminates
abnormally
© Strictly confidential 15
…DD statement…
//INPDD DD DSN=TEST01.TRY.PS, DISP=(NEW,CATLG),…

…DISP parameter
 If initial status sub-parameter is not specified, the default is NEW
 If the normal termination disposition sub-parameter is omitted, the
default is DELETE for a NEW data set or KEEP for an existing data
set
 If the abnormal termination disposition sub-parameter is omitted, the
default is the disposition specified or implied by the second sub-
parameter. However, if the second sub-parameter is specified PASS,
the default abnormal termination disposition is DELETE for a NEW
data set or KEEP for an existing data set
 If the DISP parameter itself is omitted, the default is
(NEW,DELETE,DELETE)

© Strictly confidential 16
…DD statement…
//INPDD DD DSN=TEST01.TRY.PS, DISP=(NEW,CATLG),
// UNIT=SYSDA,VOL=SER=TST01R,…
3390,SYSDA,TAPE

UNIT parameter
 Asks the system to place the data set on

◦ A specific device
◦ A certain type or group of devices
◦ The same device as another data set

© Strictly confidential 17
…DD statement…
//INPDD DD DSN=TEST01.TRY.PS, DISP=(NEW,CATLG),
// UNIT=SYSDA,VOL=SER=TST01R,…

VOL parameter
 To identify the volume or volumes on which a data set resides or will
reside. User can request
◦ A private volume
◦ Retention of the volume
◦ A specific volume by serial number
◦ The same volume that another data set uses

© Strictly confidential 18
…DD statement…
//INPDD DD DSN=TEST01.TRY.PS, DISP=(NEW,CATLG),
// UNIT=SYSDA,VOL=SER=TST01R,
// DCB=(LRECL=80,RECFM=FB,BLKSIZE=800),…

DCB parameter
 Has the following sub-parameters

◦ LRECL=n – Record length of n bytes


◦ RECFM=(F/FB/V/VB/U) – Format of data set
◦ BLKSIZE=n – Block size of n bytes
◦ DSORG=(PS/PO/DA) – Organisation of data set

© Strictly confidential 19
…DD statement
//INPDD DD DSN=TEST01.TRY.PS, DISP=(NEW,CATLG),
// UNIT=SYSDA,VOL=SER=TST01R,
// DCB=(LRECL=80,RECFM=FB,BLKSIZE=800),
// SPACE=(TRK,(1,1))

SPACE parameter
 Format: SPACE=(space units,(primary,secondary,dir),RLSE)
 space units could be TRK or CYL or block size in bytes
 primary stands for primary quantity
 secondary stands for secondary quantity
 dir specifies the number of 256-byte records needed in the directory
of a PDS
 RLSE requests that space allocated to an output data set, but not used,
is to be released when the data set is closed

© Strictly confidential 20
Additional DD statements…
SYSIN statement
 To supply data from JCL to the program being executed, SYSIN DD
statement be used
 Example:

//SYSIN DD *
Value1
Value2
/*
 Data given in SYSIN are the only exceptions in the JCL from having
the identifier // in the first column
 /* is used to indicate the end of the in-stream values
 SYSIN can also be used to refer to a data set which has the required
in-stream values, that is:
//SYSIN DD DSN=TEST01.TEST.DATA,DISP=SHR

© Strictly confidential 21
…Additional DD statements…
SYSOUT statement
 Used to route output from a step to a device
 Example:

//SYSOUT DD SYSOUT=*
 A SYSOUT data set is a system-handled output data set
 This data set is placed temporarily on direct access storage
 Later, the system prints it or sends it to a specified location

© Strictly confidential 22
…Additional DD statements
SYSABEND statement
 To request that the system dump the storage occupied by a failing
program and other storage needed to debug the program
 Example:

//SYSABEND DD SYSOUT=*

SYSPRINT statement
 Contains output of each step in a JCL
 Example:

//SYSPRINT DD SYSOUT=*
 Output of each step in the JCL is given in SYSPRINT
 By directing it to SYSOUT, the output can be seen on spooling tools
like SDSF or IOF

© Strictly confidential 23
More about DD statement
 If a particular DD is not used in a JCL step, it can be dummied out:
//SYSIN DD DUMMY
//SYSIN DD DSN=NULLFILE
 It is possible to use multiple data set names for a particular DD. In
the example below, an application program wants to process input
records from two data sets. The records from the first data set and the
second one are used one after the other
//INPDD DD DSN=TEST01.INPUT.PS1,DISP=SHR
// DD DSN=TEST01.INPUT.PS2,DISP=SHR
and so on…

© Strictly confidential 24
JOBLIB
 Defines the data set where the programs executed in a job reside
 It is placed after the JOB statement
 Example:

//TEST01R JOB 1234,(TEST JCL)


//JOBLIB DD DSN=TEST01.PROJ.LOADLIB,DISP=SHR
 DISP=SHR is mandatory
 Executable load modules of all programs executed in this job are to be
present in TEST01.PROJ.LOADLIB

© Strictly confidential 25
STEPLIB
 Similar to JOBLIB, but given at step level
 Overrides data set name for that step alone
 Example:

//STEP02 EXEC PGM=SORTPROG


//STEPLIB DD DSN=TEST01.PROJ.LOADLIB1,DISP=SHR
 Assuming that the JCL above has a JOBLIB, only for STEP02,
program SORTPROG’s load module that is present in
TEST01.PROJ.LOADLIB1 is picked up for execution
 Again, DISP=SHR is mandatory

© Strictly confidential 26

You might also like