Job Control Language (JCL)
Job Control Language (JCL)
OBJECTIVES
1
JOB CONTROL LANGUAGE (JCL)
2
JOB
• JCL control statements are organized into groups of work called Jobs.
• A JOB is simply an execution of a program or a set of related
programs in sequence
• General structure of a simple JOB.
//Job statement
//Step 1 EXEC program
// DD statements
// DD statements
//Step 2 EXEC program
// DD statements
// DD statements
//Step 3 EXEC program
// DD statements
// DD statements
// DD statements
// DD statements
//
• Each program executed by a job is called a JOB step
3
SAMPLE JCL
4
JOB EXECUTION
6
SYNTAX OF JCL (Cont…))
IDENTIFIER FIELD
7
SYNTAX OF JCL (Cont…)
Name Field
8
SYNTAX OF JCL (Cont…)
OPERATION FIELD
• It can be coded anywhere on the line, but should be separated from the
name field by at least one space
9
SYNTAX OF JCL (Cont…)
PARAMETER FIELD
• The parameter field begins at least one position after the end of operation
field and can be extended upto column 71
• Within parameter field, one or more parameters are coded, each of them
separated by commas with no intervening spaces
• Comments field begins in the position after the space that marks the end
of parameters field
10
SYNTAX OF JCL (Cont…)
Example 1:
//OUTPUT DD DSN=TRG.TRANS,DISP=(,CATLG,DELETE),
// SPACE=(TRK,(2,1)),UNIT=SYSDA
11
JOB Statement
12
JOB Statement Format
13
JOB Statement Format (Cont…)
Example :
14
JOB Statement
JOB NAME
A job statement must have a name. The absence of job name will
result in a JCL error
Format :
Example :
Remark :
Jobs with the same name cannot be executed concurrently.
However when several jobs with the same name are submitted,
they are executed sequentially.
15
Parameter Field
specified statement.
16
Accounting Information
Format :
([account-number] [,additional.accounting-info.])
Example:
//TRG001A JOB (9927,TRG)…
17
Name Parameter
Example :
18
MSGLEVEL Parameter
- Keyword parameter
- Optional
- Installation-dependent
Let’s you control the contents of JCL print and the system
messages
Format :
MSGLEVEL=([jcl][,message])
jcl : 0,1 or 2
message : 0 or 1
19
MSGLEVEL Parameter (Cont…)
Message
0 Indicates no message will be
shown except return code
20
MSGCLASS Parameter
- Keyword parameter
- Optional
- Installation-dependent
Format :
MSGCLASS=sysoutclass
21
CLASS Parameter
- Keyword parameter
- Optional
- Installation-dependent
Format :
CLASS=job class
22
PRTY Parameter
- Keyword parameter
- Optional
- Installation-dependent
Format :
PRTY=priority-no.
0 - lowest priority
15 - highest priority(for JES2)
Example :
CLASS=7,PRTY=3
23
TIME Parameter
- Keyword parameter
- Optional
Format :TIME=([minutes][,seconds]|[1440])
A no. from 1 to 59
A no. from 1 to 1439
• TIME parameter specifies the total amount of CPU time a job may
use. i.e. all the steps in a job can use collectively.
Example :
1. TIME=1440 (no time-limit)
The job will not be timed for CPU. It will also not time-out(S522
ABEND failure)
2. TIME=(3,20)
All the steps in a job are allowed collectively 3 minutes and 20
seconds of CPU time. If this amount exceeds the result will be S322
ABEND failure
24
REGION Parameter
- Keyword parameter
- Optional
- Installation-defined
Format :
REGION=value(K|M)
Example :
REGION=500K
25
REGION Parameter (Cont…)
All the steps in the job are limited to this value. If more storage is
needed the result is a S878 or S80A or S804 ABEND failure. If
one of this failure’s occurs the user must increase the value in the
REGION parameter.
Example :
REGION=0K (or 0M) is coded, the entire address space (except
those areas used by MVS/SP) is available.
Remark :
If REGION parameter is omitted, an installation defined default
will be used.
26
ADDRSPC Parameter
• The ADDRSPC parameter specifies whether the job will use Real or
Virtual storage
- Keyword parameter
- Optional
Format :
ADDRSPC={VIRT|REAL}
27
PERFORM Parameter
Syntax:
PERFORM=n
28
PERFORM Parameter
29
NOTIFY Parameter
- Keyword parameter
Format:
NOTIFY=user-id
Note:
If the NOTIFY parameter is omitted no message will appear
when the job terminates.
30
RESTART Parameter
- Keyword parameter
- Optional
Format:
RESTART={stepname|procexec.stepname|*}
Example :
RESTART=step3
31
TYPRUN Parameter
- Keyword parameter
- Optional
Format :
TYPRUN={HOLD|JCLHOLD|SCAN|COPY}
Example :
TYPRUN=SCAN
32
EXEC Statement
Format :
//[stepname] EXEC parameters
33
PGM Parameter
34
PGM Parameter (Cont...)
35
ACCT Parameter
- Keyword parameter
- Optional
- Installation-dependent
Format :
ACCT=(account-no,[additional account-info.])
36
PERFORM Parameter
Syntax:
PERFORM=n
37
PERFORM Parameter
38
PARM Parameter
- Keyword parameter
- Optional
Format :
PARM=string (a max. of 100 characters)
Note : If commas are part of the string, the entire field must
be enclosed in parenthesis or apostrophe’s
Example :
1. PARM=(A,B,C,D) or ‘A,B,C,D’
2. PARM=1005
39
PARM Parameter (Cont...)
plength contains the length of the data passed to the program and
data is placed in the variable string.
40
Failures under MVS
JCL errors
ABEND failures
Bad return (or condition) codes
41
Failures under MVS (Cont...)
Note that none of the steps of a job that contains a syntactical JCL
error can be executed, regardless of which step the error was
detected in.
42
Failures under MVS (Cont...)
Example 1:
//INFILE DD DSN=TRG.EMPFILE,DISP=(OLD,DLETE,DELETE)
Message “IEF5595 UNIDENTIFIED KEYWORD IN THE DISP FIELD”
Example 2:
//TRG001A JOB 9927,PAI,NOTIFY=&SYSUID,
// COND=((0,LT),8,NE)
Message “IEF5596 UNBALANCED PARENTHESIS IN COND FIELD”
43
Failures under MVS (Cont...)
Note: Since every step has its own allocation process, previous
steps may well have been executed. As a result, the step
where the allocation error was encountered, an all the
following steps will not be executed.
44
Failures under MVS (Cont...)
Example 1:
//INFILE DD DSN=TRG.EMPFILE,DISP=(NEW,CATLG,DELETE),
// UNIT=SYSDA,SPACE=(CYL,(100,10)),VOL=SER=PROD2
Message “IEF5597 jobname stepname ddname SPACE REQUESTED
NOT AVAILABLE” will appear in the output for specific request.
Example 2:
//INFILE DD DSN=TRG.EMPFILE,DISP=(NEW,CATLG,DELETE),
// UNIT=SYSDA,SPACE=(CYL,(100,10)),
45
COND Parameter
46
COND Parameter (Cont…)
47
COND Parameter (Cont…)
48
COND Parameter (Cont…)
49
COND Parameter (Cont…)
Syntax :
COND=((code, operator) [,....])
code = a number between 0 to 4095
operator = LT, LE, NE, EQ, GT, GE
50
COND Parameter (Cont…)
Syntax :
COND=((code, operator) [,....])
code = a number between 0 to 4095
operator = LT, LE, NE, EQ, GT, GE
Rules :
Condition is read from LEFT to RIGHT.
Maximum of 8 tests.
If COND evaluates to TRUE the step is BYPASSED.
If COND evaluates to FALSE the step is EXECUTED.
The tests that appear in the COND parameter of the JOB
statement repeat for each step.
When a COND evaluates to TRUE in a JOB statement no steps can
execute from that point onwards.
COND parameter in a JOB statement is ignored for the first step of
the job.
51
COND Parameter (Cont…)
Example :
52
COND Parameter (Cont…)
Syntax:
COND=((code,operator[,stepname])[,...][,EVEN|ONLY])
53
COND Parameter (Cont…)
Syntax:
COND=((code,operator[,stepname])[,...][,EVEN|ONLY])
54
COND Parameter (Cont…)
• The EVEN and ONLY sub parameters will have no effect under the
following conditions:
If a job exhausts available CPU time (ABEND code S322) supplied by the
TIME parameter in the JOB statement, no steps after this ABEND can be
executed. The same is not true if the ABEND is caused by TIME parameter
in the EXEC statement.
Remarks: If the COND parameter is not at all coded, the step will be
executed regardless of previous return code. However, it will not be
executed if a previous step has ABENDed.
55
COND Parameter (Cont…)
COND parameter.
56
COND Parameter (Cont…)
Example :
57
COND Parameter (Cont…)
Example :
58
COND Parameter (Cont…)
59
COND Parameter (Cont…)
Tips:
A step that is not executed issues no return code and any attempt to
interrogate the return code of such a step in the COND parameter of a
subsequent step will be ignored.
60
COND Parameter (Cont…)
Tips:
• COND=(last-good-return-code,LT)
Or
• COND=(first-bad-return-code,LE)
Or
The syntax is
// IF (relational-expression) THEN
[JCL statements (EXEC) to execute if true.]
// ENDIF
// IF (relational-expression) THEN
[JCL statements (EXEC) to execute if true
// ELSE
[JCL statements (EXEC) to execute if FALSE.]
// ENDIF
Place the IF before any EXEC statement except the first EXEC.
Restrictions
2. Both the THEN and ELSE can be null, but not both.
3. If not null, the THEN (and ELSE if one is coded) must contain at
least one EXEC statement.
63
IF-THEN-ELSE-ENDIF Statement (Cont..)
The following are the valid comparison values EQ, NE, GT, LT, GE, NL,
LE, NG.
Note that NOT has the highest priority, the comparison the second
highest, and AND and OR the lowest.
Example 1:
// IF (S1.RC GE 4 AND S1.RC LE 6) THEN
[JCL statements to execute if the return code from S1 is 4, 5, or 6.]
// ELSE
[JCL statements to execute if the return code from S1 is not 4, 5, or 6.]
// ENDIF
64
IF-THEN-ELSE-ENDIF Statement (Cont..)
Example 2:
// IF NOT ((S1.RC GE 4 AND S1.RC LE 6) OR (… ))THEN
[JCL statements to execute if the return code from S1 is 4, 5, or 6.]
// ELSE
[JCL statements to execute if the return code from S1 is not 4, 5, or 6.]
// ENDIF
65
IF-THEN-ELSE-ENDIF Statement (Cont..)
({stepname|stepname.procstepname}.ABEND)
You can code either ABEND or ABEND=TRUE. For the reverse, to test
that an ABEND did not occur, code ABEND=FALSE.
66
IF-THEN-ELSE-ENDIF Statement (Cont..)
({stepname|stepname.procstep}.ABENDCC={Sxxx|Uxxxx})
Test the system or user completion code for a particular previous step.
Test the system or user completion code for a particular previous step in
a cataloged procedure.
Example 1: S1.ABENDCC=S878
67
IF-THEN-ELSE-ENDIF Statement (Cont..)
({stepname|stepname.procstep}.RUN)
You can code either RUN or RUN=TRUE. For the reverse, to test that a
step did not execute, code RUN=FALSE.
68
IF-THEN-ELSE-ENDIF Statement (Cont..)
Example 1:
// IF (S1.RUN) THEN
//S2 EXEC PGM=ASS1
// ENDIF
// IF (S1.RUN=FALSE) THEN
//S3 EXEC PGM=ASS2
// ENDIF
Or
// IF (S1.RUN) THEN
//S2 EXEC PGM=ASS1
// ELSE
//* it yields a value of false if the step S1 did not execute
//S3 EXEC PGM=ASS2
// ENDIF
69
DD Statement - Function
70
DD Statement - Disk Datasets Format
//ddname DD DSNAME=data-set-name,
// DISP=(status, normal-disp,abnormal-disp),
// UNIT=unit,
// VOL=SER=Vol-Ser,
// SPACE=(unit,(primary[,secondary])[,dir]),
// DCB=(option,option,...)
71
DSNAME Parameter
- Keyword parameter
- Optional
Format :
DSN=name
Example :
DSN=TRG.HSBC.PAYROLL.MASTER
72
DSNAME Parameter (Cont…)
&&name
DSN=&&name
Identifies a temporary dataset.
Temporary means that it cannot be retained beyond job
termination.
Example 1:
//DD1 DD DSN=&&TEMP,UNIT=SYSDA,
// SPACE=(TRK,(2,1),RLSE),
// DISP=(,PASS,DELETE)
Example 2:
//SORTWK1 DD UNIT=SYSDA,SPACE=(TRK,(2,1),RLSE),
// DISP=(,PASS,DELETE)
73
DSNAME Parameter (Cont…) ….)
REFERBACK
*.STEPNAME.DDNAME : Requests that the dataset name be copied
from DD statement ‘ddname’ found in a previous step ‘stepname’.
DSN=*.STEP2.OUT
*.DDNAME : Requests that the dataset name be copied from a
previous DD statement ‘ddname’ found in the same step. Seldom
used.
DSN=*.DD1
*.PROCEXEC.STEPNAME.DDNAME : Requests that the dataset name
be copied from DD statement ‘ddname’ found in a previous step
‘stepname’ found within procedure ‘procexec’.
DSN=*.PS4.STEP2.OUT
74
DSNAME Parameter(Cont…)
M12 EXISTS
75
DISP Parameter
DISP Parameter
- Keyword parameter
- Optional
Format :
DISP=(status-fld,normal-disp-fld,abnormal-disp-fld)
76
DISP Parameter (Cont...)
77
DISP Parameter (Cont...)
NEW - The dataset does not exist and should be created in this step.
OLD - The dataset exists and should be allocated for exclusive use.
SHR - The dataset exists and should be allocated for shared use.
78
DISP Parameter (Cont...)
2. Indicates that the dataset will be created. This will be true if:
– the DD statement contains neither VOL=SER nor VOL=REF and it
describes a dataset which is neither cataloged nor passed
79
DISP Parameter (Cont...)
80
DISP Parameter (Cont...)
Remark :
1. If the abnormal disposition field is omitted, the default is the normal
disposition field.
81
UNIT and VOLUME Parameters
Format:
device address
UNIT=( generic device name [,device-count] [,DEFER])
generated device name
Example 1:
UNIT=3380 ; UNIT=3400-5 ; UNIT=(3390,2)
UNIT=SYSDA ; UNIT=DISK ; UNIT=TAPE
82
UNIT Parameter
83
VOLUME Parameter
SER=(VOL1[,VOL2], ....]
VOL= REF=referback
REF=dsname
Remark:
The maximum no. of volumes is 255 and there is no default for
VOL=SER or VOL=REF.
84
SPACE Parameter
Format :
SPACE=(
{ } CYL,
TRK,
blksize,
(prim-alloc[,sec-alloc][,directory) [,RLSE] )
85
SPACE Parameter (Cont…)
Example :
SPACE=(23440,(200,50,2))
86
SPACE Parameter (Cont…)
Note :
87
LABEL Parameter
Format :
LABEL=([seq-no][,type])
88
LABEL Parameter (Cont…)
Example :
1. LABEL=(2, SL)
2. LABEL=(, NL)
89
LABEL Parameter (Cont…)
//OUT DD DSN=TRG.TAPE,
// DISP=(,CATLG,DELETE),UNIT=TAPE,
// DCB=(BLKSIZE=32720,LRECL=80,RECFM=FB)
//* LABEL not supplied - the default is (1,SL)
//OUT DD DSN=TRG.TAPE,
// DISP=(,KEEP),UNIT=TAPE,LABEL=(,NL),
// DCB=(BLKSIZE=32720,LRECL=80,RECFM=FB)
//* LABELs are used
90
DCB Parameter
Format :
DCB=([referback] | [model] [, subparm] , ..... )
Example :
DCB = (DSORG=PS,RECFM=FB,LRECL=80,BLKSIZE=800)
92
Commonly used DCB Parameters (Cont..)
Remarks :
1. A DCB will exist for every non-VSAM dataset to be opened by the
program (for input or output). Certain values must be hard coded by
the program itself. Others can be left out, giving the user the option of
supplying these values via the DCB parameter as well as other means.
S013-20 ABEND when RECFM=FB is used but the block size is not an
exact multiple of logical record length.
S013-34 ABEND when RECFM=FB is used and the LRECL is greater
than the BLKSIZE.
S013-34 ABEND when RECFM=VB is used and the LRECL is greater
than the BLKSIZE-4.
S001-04 ABEND when BLKSIZE in the DCB parameter is smaller than
the actual block size and a multiple of the LRECL in the DSCB of the
dataset.
93
In-Stream Data Format
*
//ddname DD DATA,DLM=XX
Example 1 :
//INPUT DD *
A0014214 CHAR
A0024342 DABL
/*
Example 2 :
//SYSIN DD *
1234XYZ
2345HSBC
//DD1 DD DSN=TRG.HSBC.PAYROLL.MASTER,…
94
SYSOUT Parameter
Format :
SYSOUT=(class | *)
Example 1 :
//SYSUT1 DD SYSOUT = C
//ddname DD SYSOUT = *
95
DD Statement - Concatenation
96
DD Statement – Concatenation (Cont…)
97
DUMMY Parameter
//ddname DD DUMMY
It is a positional parameter.
//ddname DD DSN=NULLFILE or
//ddname DD DUMMY
98
DUMMY Parameter (Cont…)
Remarks:
99
THE JOBLIB DD Statement
100
THE JOBLIB DD Statement
//JOBLIB DD DSN=TEST.LOADLIB,DISP=SHR
// DD DSN=TEST.MYLIB,DISP=SHR
// DD DSN=PROD.LOADLIB,DISP=SHR
101
THE STEPLIB DD Statement
102
THE STEPLIB DD Statement (Cont…)
103
STORAGE DUMP
- A SYSUDUMP DD statement
- A SYSMDUMP DD statement
- A SYSABEND DD statement
//SYSUDUMP DD SYSOUT = *
-all virtual storage allocated to your program i.e. user region of
JOB’s private address space
// SYSABEND DD SYSOUT = *
-user region + system areas outside the user region that are
associated with the job step
// SYSMDUMP DD SYSOUT = *
- system areas + entire private address space
104
STORAGE DUMP (Cont…)
//SYSDUMP DD SYSOUT=*
//SYSDUMP DD DSN=TRG.DUMP1,
// DISP=(,DELETE,CATLG),UNIT=SYSDA,
// SPACE=(CYL,(0,5),RLSE)
Remark :
When more than one of the above statements is included in the JCL of
a step, only the last one will be used.
105
APPENDIX - A
106
JOB CONTROL LANGUAGE (JCL)
Thank You
107