0% found this document useful (0 votes)
432 views108 pages

Job Control Language (JCL)

Uploaded by

Lalit Kumar
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
432 views108 pages

Job Control Language (JCL)

Uploaded by

Lalit Kumar
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd

JOB CONTROL LANGUAGE (JCL)

OBJECTIVES

OBJECTIVES OF THIS HAND-OUT


- To teach participants about the importance of JCL in batch job processing.
- To make participants understand about JOB, EXEC & DD statements.
- To familiarize participants with the variety of PARAMETERS that are being
used in all types of JCL statements.
- To make participants aware about some other forms of DD statements.
- To make participants understand the PROCEDURE handling in JCL &
types of over-ride.
- To deal with various utilities within JCL.

AT THE END OF THE COURSE YOU WILL BE ABLE TO...


- submit & execute the batch job through JCL.
- tackle the most frequently used parameters within JCL as per your batch
job requirement.
- use the utilities in JCL
- handle the procedures within JCL with over-rides.

1
JOB CONTROL LANGUAGE (JCL)

• JCL is a language which allows users to communicate with the


operating system

• JCL step tells the operating system

– The name, location of the application program and its components,


OS components etc, to be processed
– The name and location of the data files needed by the application
program
– The hardware devices needed by the application program to achieve
its function

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

//TRG001A JOB 9927,HSBC,MSGCLASS=U,MSGLEVEL=(1,1),


// NOTIFY=TRG001
//SORT1 EXEC PGM=SORT
//SYSPRINT DD SYSOUT = *
//SYSOUT DD SYSOUT = *
//SORTIN DD DSN=TRG.TRANFILE,DISP=SHR
//SORTOUT DD DSN=TRG.TRANSORT,
// DISP=(NEW,CATLG,DELETE),UNIT=SYSDA,
// SPACE=(TRK,(1,1)),
// DCB=(RECFM=FB,LRECL=400,BLKSIZE=3200)
//SORTWK01 DD UNIT=SYSDA, SPACE=(CYL,(1,1))
//SYSIN DD *
SORT FIELDS=(16,5,CH,A)
/*
//

4
JOB EXECUTION

Execution of a Job by an Initiator


© Copyright 2002 - 2006 HSBC Software Development India Pvt. Ltd. All rights reserved. 5
SYNTAX OF JCL

• JCL statements are coded in 80-byte records

• Only 72 characters are used to code JCL statements

• Within 72 characters, JCL statements can be coded in a relatively


free-form manner, with just few restrictions

• Each JCL statement is divided into many fields

6
SYNTAX OF JCL (Cont…))

JCL STATEMENT FORMAT:

//name operation parm1,parm2 … comments

IDENTIFIER FIELD

• Identifier field identifies a record as a JCL statement


• For most JCL statements, this field occupies first two character positions
and contains two slashes (//)
• Two exceptions are delimiter statement that contains a slash and a
start(/*) and comment statement having Identifier field as (//*)

7
SYNTAX OF JCL (Cont…)

Name Field

The name field associates a name with a JCL statement

• Always required on a JOB statement


• Name field must start from column 3
• Has to be 8 characters in length
• Consists of letters, numbers or national characters (#, @ and $)
• First character of a name must be a letter or national character

8
SYNTAX OF JCL (Cont…)

OPERATION FIELD

• The operation field specifies the statement's function

• It can be coded anywhere on the line, but should be separated from the
name field by at least one space

• Statements that do not have operation field are:


• /* ------ Delimiter
// ------ Null
//* ------ Comment

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

• Parameters supply information that influence on how a statement is


processed

• Comments field begins in the position after the space that marks the end
of parameters field

10
SYNTAX OF JCL (Cont…)

Rules for Continuation


The JCL statement can be continued into the next line by coding two
slashes at the beginning of the line and continuing in the parameter field
starting anywhere between positions 4 and 16 (inclusive )

Note :A comma enclosed in a apostrophe’s cannot be used for


continuation

Example 1:

//OUTPUT DD DSN=TRG.TRANS,DISP=(,CATLG,DELETE),
// SPACE=(TRK,(2,1)),UNIT=SYSDA

11
JOB Statement

• The JOB statement is the first statement to be coded for a JCL

• It has three basic functions :


It identifies a job to MVS and supplies a job name that MVS uses to refer
to the job

It supplies accounting information to MVS

It supplies various options that influence or limit how the job is


processed

12
JOB Statement Format

• The format of a job statement :

//jobname JOB ([account-no] [,additional, accounting-info.]),


// Programmer’s name, MSGCLASS=class,
// MSGLEVEL=([jcl] [,message]), NOTIFY=user-id,
// USER=user-id, PASSWORD=password,
// CLASS=jobclass,
// ADDRSPC={VIRT|REAL},
// TIME=([minutes][,seconds]|[1440]),
// REGION=Value{K|M},
// PRTY=priority,
// RESTART={stepname|procexec.stepname|*},
// TYPRUN={HOLD|JCLHOLD|SCAN|COPY},
// COND=(test[,test].....)

13
JOB Statement Format (Cont…)

Example :

// TRG001A JOB (9927,TRG),HSBC,


// MSGCLASS=U,
// MSGLEVEL=(1,1),
// NOTIFY=TRG,
// TIME=(2,3),
// REGION=500K,
// TYPRUN=SCAN,
// RESTART=stepname

14
JOB Statement

JOB NAME

A job statement must have a name. The absence of job name will
result in a JCL error

Format :

//job name JOB parameters

Example :

//TRG001A JOB parameters

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

• In JCL, there are two types of parameters:

Positional - These parameters should come in JCL as per the sequence

in which they are expected.

Keyword - These parameters can appear in any sequence in the

specified statement.

16
Accounting Information

Accounting information is a positional parameter.


If present, it must be the first in the parameter field of the JOB
statement
This parameter consists of several positional parameters, first of
which is account no.
The account number is an alphanumeric field from 1 to 4 characters
long(more than 4 is also permitted).
Maximum size is 142 characters.
It is normally used to determine how the billing is to be done

Format :
([account-number] [,additional.accounting-info.])
Example:
//TRG001A JOB (9927,TRG)…

17
Name Parameter

It is a positional parameter and follows accounting information


Installation-dependent.
Maximum size is 20 characters

Note : If it contains any special characters other than a hyphen, and a


period in the middle or the beginning but not at the end of the
name, the name must be enclosed in apostrophes.

Example :

//TRG001A JOB 9927,’O’’Kelly’,...

18
MSGLEVEL Parameter

- Keyword parameter
- Optional
- Installation-dependent

Let’s you control the contents of JCL print and the system
messages

MSGLEVEL lets us specify the type of messages we want to be


included in our output

Format :
MSGLEVEL=([jcl][,message])

jcl : 0,1 or 2
message : 0 or 1

19
MSGLEVEL Parameter (Cont…)

JCL Value Definition


0 Print the job statement

1 Print all the JCL statements


along with the PROCEDURES

2 Print only JCL statements

Message
0 Indicates no message will be
shown except return code

1 All messages will be shown


viz : allocation & termination
messages

20
MSGCLASS Parameter

- Keyword parameter
- Optional
- Installation-dependent

Format :

MSGCLASS=sysoutclass

sysoutclass is a one character code viz., A-Z, 0-9 max. In all 36


output classes
MSGCLASS specifies an output class that's associated with the jobs
message output
MVS assigns a default, if the parameter is omitted

21
CLASS Parameter

- Keyword parameter
- Optional
- Installation-dependent

Format :
CLASS=job class

It assigns an input class to a job.


A job class is a one character code.
Values assigned can be A-Z, 0-9
CLASS parameters specifies class in which the job is to scheduled

Note : Each job class has its own input queue

22
PRTY Parameter

- Keyword parameter
- Optional
- Installation-dependent

PRTY specifies the scheduling priority of a job in relation to other


jobs within the same job class.

Format :
PRTY=priority-no.

For JES2, it is a number between 0 & 15


For JES3, it is a number between 0 & 14

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

REGION specifies the amount of storage a job step is allocated


(Max. storage requirement)

Format :
REGION=value(K|M)

Value - 1 to 2096128 if K is used.


Value - 1 to 2047 if M is used (M is not available to MVS/SP)

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.

When the amount of storage requested in the REGION parameter


is higher than the address space can provide, an S822 ABEND
failure will result

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}

Note : ADDRSPC=REAL is a parameter disallowed in practically all


installations because of performance problems.

27
PERFORM Parameter

• The PERFORM parameter determines the availability of three


major resources viz., CPU, real storage pages, and I/O operations.
It is nothing but an in-execution priority parameter.

Syntax:
PERFORM=n

N is a number from 1 to 999 and identifies the performance


group that the job will belong to.

Remarks: A job belonging to a performance group will be limited to a


certain number of service units (SUs) per second,
which varies according to the work load of the system.

28
PERFORM Parameter

• This parameter is seldom permitted in the testing environment


• Typically, used in production environment for certain jobs like
CICS where high resources are required.
• Installation-dependent will be assumed if this parameter is
omitted.
• If no installation-defined default exists, a system default will be
used: PERFORM=1.

29
NOTIFY Parameter

- Keyword parameter

Format:
NOTIFY=user-id

The NOTIFY parameter informs a TSO user when his/her job


terminates

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|*}

The RESTART parameter requests that a job begin its execution


with a step other than the first one.

Example :

RESTART=step3

31
TYPRUN Parameter

- Keyword parameter
- Optional

Format :

TYPRUN={HOLD|JCLHOLD|SCAN|COPY}

The TYPRUN parameter requests special processing for the job.

Example :

TYPRUN=SCAN

- will check the JCL for syntactical JCL errors

32
EXEC Statement

An EXEC statement identifies the step during the reading process


when a Job is submitted to the system.

Format :
//[stepname] EXEC parameters

Note : Stepname is optional. When the stepname is omitted no


reference can be made to that step. A job can contain a
maximum of 255 EXEC statements.

33
PGM Parameter

PGM parameter specifies the name of the program to be executed in


a step.
Format :
PGM=program-name - (load-module)
Remark :
The program specified in PGM is always a member of a PDS which is
called a load library or an executable program library.
Example :
//STEPNAME EXEC PGM=XYZ
//STEPLIB DD DSN=TRG.LIB.LOAD,DISP=SHR
or
//TRG001A JOB .......
//JOBLIB DD DSN=TRG.LIB.LOAD,DISP=SHR

If neither JOBLIB nor STEPLIB is coded, system searches certain


predefined libraries (i.e system default libraries). If the specified
member is found, it is executed. If not found the result is S806
ABEND failure.

34
PGM Parameter (Cont...)

The following keyword parameters can be specified at the EXEC


statement. The parameters are REGION, ADDRSPC, TIME, COND,
ACCT, PARM.
Remarks :
1. When REGION and ADDRSPC parameter are coded in both the JOB
and EXEC statement within a job, the value of the JOB statement
will be used.
2. If TIME parameter is coded in both the JOB & EXEC statements
within a job, both will be in effect, and either can cause a S322
ABEND failure.
3. These parameters will be used for that step only.
Example :
//S1 EXEC PGM=PAYPGM1,PARM='0791'

35
ACCT Parameter

- Keyword parameter
- Optional
- Installation-dependent

Format :
ACCT=(account-no,[additional account-info.])

ACCT parameter specifies accounting information to be used for


the step as opposed to the Accounting information in the JOB
statement

Note : If an account-no is also coded in the JOB statement, the


account-no in the EXEC statement will be used.

36
PERFORM Parameter

• The PERFORM parameter determines the availability of three


major resources viz., CPU, real storage pages, and I/O operations.
It is nothing but an in-execution priority parameter.

Syntax:
PERFORM=n

N is a number from 1 to 999 and identifies the performance group


that the job will belong to.

Remarks: A job belonging to a performance group will be limited to a


certain number of service units (SUs) per second, which
varies according to the work load of the system.

37
PERFORM Parameter

• This parameter is seldom permitted in the testing environment


• Typically, used in production environment for certain jobs like
CICS where high resources are required.
• Installation-dependent will be assumed if this parameter is
omitted.
• If no installation-defined default exists, a system default will be
used: PERFORM=1.
• If the PERFORM parameter is also coded in the JOB statement the
value in the JOB statement will be used

38
PARM Parameter

- Keyword parameter
- Optional

PARM parameter provides a way to supply data of limited


size to the executing program

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...)

In COBOL the following must be coded


LINKAGE SECTION.
01 PARM.
05 plength PIC S9(4) COMP.
05 pstring PIC X(100).
PROCEDURE DIVISION USING PARM.

plength contains the length of the data passed to the program and
data is placed in the variable string.

40
Failures under MVS

The types of failure a JCL user can encounter in an MVS


environment and the three general causes of failures are:

JCL errors
ABEND failures
Bad return (or condition) codes

41
Failures under MVS (Cont...)

JCL Errors: are of two types:


A syntactical JCL error
An allocation error

• Syntactical JCL Errors


A syntactical JCL error is detected when a job is submitted and read into
the system. It will occur when a JCL statement or parameter violates the
syntax rules of JCL.

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...)

A message always appear in the output of the job that describe


the error. In most cases, such messages are self-explanatory.

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...)

Allocation JCL Errors:


An allocation JCL error is detected when a step goes through the
allocation routines. A problem is detected while attempting to allocate or
locate a resource such as a data set, a volume, a device, etc needed by
a DD statement in the step.

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)),

Message “IEF5598 jobname stepname ddname INSUFFICIENT SPACE


ON STORAGE VOLUMES” will appear in the output for non-specific
request.

45
COND Parameter

By COND mechanism, a user can control the execution of steps


within a job.

Conditional execution of steps within a job.

Can be coded in a JOB or EXEC statement or both.

Return code (or Condition code) is a number between 0 and 4095,


issued by an executing program just before execution is finished.
It is intended to identify an important event such as record not
found (code 23) or out of sequence (code 21) or issue a return
code of 0 to indicate that the execution was trouble-free.

46
COND Parameter (Cont…)

The return code issued by the executing program is saved by the


system for the duration of the job and is never available to other
jobs. Any subsequent step of the same job can interrogate this
return code by using the COND parameter either in the JOB or
EXEC statement. The result of this interrogation is to either permit
or bypass the execution of the step.

47
COND Parameter (Cont…)

All programming languages provide a means by which the return


code can be issued.

In Assembly language we use register 15 to return a value of 7.


LA 15,7
BR 14

In COBOL the same can be done by coding


MOVE 7 TO RETURN-CODE.

48
COND Parameter (Cont…)

The instruction that issues the return code is optional. However,


it is recommended that all programs be written to contain such
an instruction but the fact remains that it can be omitted. If so, a
default return code will be supplied.

For high-level languages, such as COBOL, the default is 0. For


Assembly Language, the default is unpredictable

49
COND Parameter (Cont…)

For JOB statement

Syntax :
COND=((code, operator) [,....])
code = a number between 0 to 4095
operator = LT, LE, NE, EQ, GT, GE

The COND parameter at the JOB statement can perform a test or


multiple test at the beginning of each step against the return
codes issued by the previous steps. If a test is evaluated to false
that step will be executed and if it evaluates to true, none of the
steps from that point on will be executed.

50
COND Parameter (Cont…)

For JOB statement

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…)

For JOB statement (Contd ..)

Example :

Consider a job with 5 steps.


Assume that none will ABEND.

//TRG001A JOB 9927,HSBC,COND=((12,LT),(8,EQ))

STEP1 issues a return code of 0


STEP2, if executed, issues a return code of 4
STEP3, if executed, issues a return code of 16
STEP4, if executed, issues a return code of 0
STEP5, if executed, issues a return code of 4

52
COND Parameter (Cont…)

For EXEC statement

The COND parameter at the EXEC statement can perform a test or


multiple test before a step begins execution against the return codes
issued by the previous steps. If a test is evaluated to false that step
will be executed and if it evaluates to true, that step will not be
executed.

Syntax:
COND=((code,operator[,stepname])[,...][,EVEN|ONLY])

53
COND Parameter (Cont…)

For EXEC statement

Syntax:
COND=((code,operator[,stepname])[,...][,EVEN|ONLY])

EVEN requests that execution be permitted even though any


previous step has ABENDed (If no step has ABENDed then EVEN
condition is ignored)

ONLY requests that execution be permitted only if previous step has


ABENDed (If no step ABENDs the COND parameter is ignored)

If COND parameter is coded in both the JOB and EXEC statement,


the JOB statement ‘s COND is tested first and then the COND
parameter of the EXEC statement is tested.

54
COND Parameter (Cont…)

• EVEN and ONLY are mutually exclusive and has no positional


significance.

• The EVEN and ONLY sub parameters will have no effect under the
following conditions:

If a job is cancelled by the operator (ABEND code S222 or S221), no


steps after the cancellation can be executed.

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…)

• Following table will help you in solving queries related with

COND parameter.

COND JOB EXEC

TRUE TERMINATE BYPASSED

FALSE CONTINUES EXECUTED

56
COND Parameter (Cont…)

Example :

//TRG001A JOB 9927,HSBC,COND=(10,LT)


//STEP1 EXEC PGM=AAA (6)
//STEP2 EXEC PGM=BBB,
// COND=((2,EQ),(4,EQ)) (2)
//STEP3 EXEC PGM=CCC,COND=ONLY (4)
//STEP4 EXEC PGM=DDD, (6)
// COND=(5,GT,STEP1),(2,EQ))
//STEP5 EXEC PGM=EEE (9)
//STEP6 EXEC PGM=FFF, (10)
// COND=((8,GT,STEP5),EVEN)
//STEP7 EXEC PGM=GGG, (12)
// COND=(4,GT,STEP4)
//STEP8 EXEC PGM=HHH --
//STEP9 EXEC PGM=III, COND=ONLY --

57
COND Parameter (Cont…)

Example :

//TRG001A JOB ......


//S1 EXEC PGM=P1 (4)
//S2 EXEC PGM=P2,
// COND=((0,LT,S1),EVEN) (12)
//S3 EXEC PGM=P3,COND=(8,LT,S2) (0)
//S4 EXEC PGM=P4,COND=(4,LT) (8)
//S5 EXEC PGM=P5,
// COND=((4,LT,S1),(0,LT,S3) ABEND
//S6 EXEC PGM=P6, (16)
// COND=(EVEN,(0,LT,S1),(12,LT,S3))
//S7 EXEC PGM=P7, (0)
// COND=((0,LT,S1),(12,LT,S3))
//S8 EXEC PGM=P8,
// COND=((16,EQ,S6),ONLY) (0)
//S9 EXEC PGM=P9,COND=EVEN (4)
//S10 EXEC PGM=P10, COND=ONLY (0)

58
COND Parameter (Cont…)

//TRG001A JOB 9927,HSBC,COND=(5,EQ)


//STEP1 EXEC PGM=A (4)
//STEP2 EXEC PGM=B,COND=(7,LT) ABEND
//STEP3 EXEC PGM=C, --
// COND=((20,GT,STEP1),EVEN)
//STEP4 EXEC PGM=D, (6)
// COND=((3,EQ),ONLY)
//STEP5 EXEC PGM=E, --
// COND=(2,LT),STEP3)
//STEP6 EXEC PGM=F --
//STEP7 EXEC PGM=G, (5)
// COND=((6,EQ,STEP5),ONLY)
//STEP8 EXEC PGM=H,COND=EVEN --
//STEP9 EXEC PGM=I --

59
COND Parameter (Cont…)

Tips:

A program always issues a return code intentionally or by default if the


program terminates normally and intentionally returns control to the
OS.

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.

When an ABEND occurs, the program losses control instantly and is


flushed by the system. As a result, when a step ABENDs, no return code
exists but completion code exists. Only those step that has EVEN or
ONLY specified in the COND parameter of the EXEC statement will be
checked.

60
COND Parameter (Cont…)

Tips:

A formula can be devised and used to code the COND parameter, if


return code conventions are strictly adhered to.

• COND=(last-good-return-code,LT)
Or
• COND=(first-bad-return-code,LE)

Example 1:0-4 is a good return code:


4 being the last good return code, we may code COND=(4,LT).

Or

5 being the first bad return code, we may code COND=(5,LE).


The above two are logically equivalent.

Exercise: 0 is the only good return code.


61
IF-THEN-ELSE-ENDIF Statement

The IF-THEN-ELSE-ENDIF statement provides a simple means of


selectively executing job steps.

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.

Note:You can nest IF-THEN-ELSE-ENDIF statements up to 15 levels.


62
IF-THEN-ELSE-ENDIF Statement (Cont…)

Restrictions

1. JOB, JOBLIB, JOBCAT, JCLLIB, SYSCHK, and XMIT JCL statements


can’t follow THEN or ELSE.

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.

4. PROC, PEND, JES2 and JES3 statements, JCL command statements,


//*, INCLUDE statements, /*, // and SET statements can be placed
in a THEN or ELSE, but they are executed unconditionally.

63
IF-THEN-ELSE-ENDIF Statement (Cont..)

You code the relation-expression as


({stepname|stepname.procstepname}.RC comparison number)

The following are the valid comparison values EQ, NE, GT, LT, GE, NL,
LE, NG.

Relational operators are AND and OR

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..)

You can also code the relation-expression as follows:

({stepname|stepname.procstepname}.ABEND)

Test if an ABEND occurred in a particular previous step or


Test if an ABEND occurred in a particular previous step in a cataloged
procedure.

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..)

You can also code the relation-expression as follows:

({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..)

You can also code the relation-expression as follows:

({stepname|stepname.procstep}.RUN)

Test that a particular previous step executed


Test that a particular previous step in a cataloged procedure executed.

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

Data Definition (DD) statement describes the datasets that must


be allocated

One DD statement for each dataset the program will processed

DD statements are coded after the EXEC statement that identifies


the job step

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

Always required for a permanent dataset


It supplies the dataset name as it is stored in the datasets label or
file catalog's entry.
DSN (or DSNAME) parameter identifies the name of the dataset
to be created.

Format :
DSN=name
Example :
DSN=TRG.HSBC.PAYROLL.MASTER

To refer to a member of a PDS:


//TRANFILE DD DSN=TRG.HSBC.TRANFILE(mem1)

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)

This also creates a temporary dataset

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…)

//S1 EXEC PGM=P1


//D1 DD DSN=TRG.LIB(M12),
// DISP=SHR

M12 EXISTS

P1 opened in I/P mode for reading, M12 is read.


P1 opened in O/P mode for writing, M12 will be replaced (but not in
place).

M12 DOES NOT EXIST


P1 opened in I/P mode for reading, ABEND (S013-18).
P1 opened in O/P mode for writing, M12 will be created and written
into.

75
DISP Parameter

DISP Parameter
- Keyword parameter
- Optional

Format :
DISP=(status-fld,normal-disp-fld,abnormal-disp-fld)

NEW ,DELETE ,DELETE


OLD ,KEEP ,KEEP
DISP= (SHR ,CATLG, CATLG )
MOD ,UNCATLG ,UNCATLG
,PASS

The DISP parameter has three positional sub-parameters:


- Status
- Normal Disposition
- Abnormal Disposition

76
DISP Parameter (Cont...)

Status specifies whether the file is to be created or retrieved in this


step

Normal disposition specifies, what is to be done with the dataset,


when the step terminates normally (without an ABEND)

Abnormal disposition specifies, what is to be done with dataset,


when the step terminates abnormally. (it is required if this
disposition is different from the normal disposition)

77
DISP Parameter (Cont...)

Example : DISP = (NEW,CATLG,DELETE)

Value of Status Sub-parameter

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.

MOD - This sub-parameter has two possible meanings:

78
DISP Parameter (Cont...)

MOD - This sub-parameter has two possible meanings:

1. Indicates that an existing dataset will be retrieved. This will be true


if:
– the data set is either cataloged or passed OR

– the DD statement contains either VOL=SER or VOL=REF

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

– The DD statement contains VOL=REF referring to a dataset, which


is non-specific request for a new dataset.

79
DISP Parameter (Cont...)

DD Statement-Values of Normal & Abnormal disp-parameter

DELETE - The dataset is deleted & uncataloged when the step


terminates normally (or abnormally).
KEEP - The dataset is to be retained when the step terminates normally
(or abnormally).
CATLG - The dataset is retained and an entry made in the catalog when
the step terminates normally (or abnormally).
UNCATLG - The dataset retained but entry removed from catalog when
the step terminates normally.
PASS - Normal disposition only, the dataset is retained for use by a
later step.

80
DISP Parameter (Cont...)

DD Statement-Values of Normal & Abnormal disp-parameter

NOTE : PASS is not permitted in the abnormal disposition field.

Remark :
1. If the abnormal disposition field is omitted, the default is the normal
disposition field.

2. When a dataset specified in DSN does not exist then S213-04


ABEND failure occurs i.e., dataset does not exist.

81
UNIT and VOLUME Parameters

UNIT and VOLUME parameters work together to specify the location


of the dataset.
UNIT indicates
– the device type or device address on which the dataset resides on a
volume.
– The no. of devices to be allocated to the dataset.
– When the mount message is to be shown to the operator
There is no default for UNIT.

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

UNIT parameter can be coded in any one of the following three


ways :

– By specifying the device address


Example: UNIT=301

– By specifying the generic name that identifies a particular type


of device
Example: UNIT=3380

– By specifying a Group name that specifies devices that belong


to categories set up by the installation
Example: UNIT=TAPE

83
VOLUME Parameter

VOLUME indicates Vol-Ser of the dataset's volume

UNIT and VOLUME parameters not needed for cataloged datasets.

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] )

SPACE parameter is coded for Non-VSAM datasets, to specify how


much space to be allocated to the dataset.
It has two positional sub-parameters, the second sub-parameter has
3 positional parameters.
The first sub-parameter indicates the unit of measure used for
space allocation.
Example :
SPACE=(CYL,(10,1))
SPACE=(800,(500,100))

85
SPACE Parameter (Cont…)

Second sub-parameter of SPACE parameter indicates how much


space to allocate to the dataset

3 positional sub-parameters specify


- Primary
- Secondary
- Directory space

Directory allocation is only for PDS

Unit of measure for directory is directory blocks (256 bytes each).

Example :

SPACE=(23440,(200,50,2))

86
SPACE Parameter (Cont…)

Note :

1. When the directory is exhausted, the result is an S013-14 ABEND


failure.

2. The directory quantity, if not coded defaults to zero i.e. a


sequential dataset.

3. When the secondary space is exhausted, the result is SB37-04


ABEND failure for a sequential dataset and SE37-04 ABEND
failure for a PDS.

4. There is no default for primary allocation (coding 0 is allowed) and


secondary and directory space if omitted, defaults to zero.

87
LABEL Parameter

The LABEL parameter can specify :


- The sequence of a tape dataset on a volume
- The type of label of the dataset

Format :
LABEL=([seq-no][,type])

seq-no - Identifies the sequence number of the dataset on a tape


volume. 1 to 4 digits. If omitted, it defaults to 1. If 0 is coded, it
defaults to 1. maximum : 9999
Note :
The sequence number is ignored when :
- retrieving a tape dataset through the catalog
- receiving a passed tape dataset.

type - Identifies the type label for the dataset


There are many types of labels :

88
LABEL Parameter (Cont…)

SL - Indicates IBM standard label. If the


sub-parameter is omitted, SL is the default.
NL - Indicates that no labels are used. NL is not commonly used.

Normally NL is used for a tape coming from or going to another


installation which has no SL capabilities.

Example :
1. LABEL=(2, SL)
2. LABEL=(, NL)

Defaults : If omitted, the LABEL parameter defaults to


(1, SL).
There are 4 ways to supply the same information:
- Omit the label parameter
- Code LABEL=(1,SL)
- Code LABEL=(,SL) 1 is the default
- Code LABEL=1 SL is the default

89
LABEL Parameter (Cont…)

Example 1 : (Creating labeled tape dataset)

//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)

Example 2 : (Creating non-labeled tape dataset)

//OUT DD DSN=TRG.TAPE,
// DISP=(,KEEP),UNIT=TAPE,LABEL=(,NL),
// DCB=(BLKSIZE=32720,LRECL=80,RECFM=FB)
//* LABELs are used

90
DCB Parameter

DCB parameter specifies characteristics that are stored in the file's


Data Control Block.
No DCB parameter is required, if the application program supplies the
required information.

Format :
DCB=([referback] | [model] [, subparm] , ..... )

Format for referback


*.stepname.ddname
*.ddname
*.procexec.stepname.ddname
Model specifies the name of a dataset which must be cataloged and
resides on disk.
This dataset is called a model DSCB.
Example :
DCB=PROD.MODEL
Sub Parameters are BLKSIZE, LRECL, RECFM, DEN, BUFNO and
DSORG.
91
Commonly used DCB Parameters

DSORG = XX Specifies the datasets organization


PS = Physical Sequential
PO = Partitioned
DA = Direct
IS = Indexed Sequential

RECFM = XX Format of the file's records

F = Fixed length, unblocked


FB = Fixed length, blocked
V = Variable length, unblocked
VB = Variable length, blocked
LRECL = n length of file's records
BLKSIZE = n length of file's block

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.

2. ABEND failures when supplying inconsistent DCB values:

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

* and DATA are positional parameters that follow DD.

Example 1 :
//INPUT DD *
A0014214 CHAR
A0024342 DABL
/*

Example 2 :
//SYSIN DD *
1234XYZ
2345HSBC
//DD1 DD DSN=TRG.HSBC.PAYROLL.MASTER,…

94
SYSOUT Parameter

The SYSOUT parameter


SYSOUT parameter can assign sysout or output class, to a dataset.
Such datasets are called sysout or output datasets.
Keyword parameter

Format :
SYSOUT=(class | *)

class - identifies the sysout class of the dataset from A-Z


and 0-9
* - indicates the same class used in the MSGCLASS parameter of the
JOB statement (or the installation-defined default, if MSGCLASS is
omitted) is to be used.

Example 1 :
//SYSUT1 DD SYSOUT = C
//ddname DD SYSOUT = *

95
DD Statement - Concatenation

Only sequential and partitioned datasets can be concatenated.


For sequential datasets, the maximum no. of concatenation is 255
and for PDS it is 16.
Concatenation has meaning only for sequential processing.

Example 1: concatenation of PS files


Concatenated Datasets :
//ddname DD DSN=TRG.HSBC.SEQ1,DISP=SHR
// DD DSN=TRG.HSBC.SEQ2,DISP=SHR
// DD DSN=TRG.HSBC.SEQ3,DISP=SHR

Example 2 : concatenation of PDS’s


//ddname DD DSN=TRG.PDS1,DISP=SHR
// DD DSN=TRG.PDS2,DISP=SHR
// DD DSN=TRG.PDS3,DISP=SHR

96
DD Statement – Concatenation (Cont…)

Rules and Restrictions for Concatenation :

1. LRECL, RECFM must be same but BLKSIZE could be different.

2. The block size of the first concatenation must be greater than or


equal to block sizes of all subsequent concatenation. Violation of
this rule results in S001-4 ABEND failure.

3. Both sequential datasets and partitioned datasets can be


concatenated but not with each other i.e Sequential with
Sequential and Partitioned with Partitioned only.

97
DUMMY Parameter

//ddname DD DUMMY

Allocates no devices no input/output ; read/write operations.

It is a positional parameter.

Physical sequential files and VSAM files can be dummied.

PDS cannot be dummied.

PDS (member) is treated as a PS file and therefore can be dummied.

//ddname DD DSN=NULLFILE or

//ddname DD DUMMY

98
DUMMY Parameter (Cont…)

Remarks:

1. When an attempt to dummy a PDS is made will cause an S013-64


ABEND failure.

2. The DCB parameter may be required while coding dummy. Failure to


do so may cause an S013-10 ABEND failure.

3. NULLFILE is a keyword parameter and is same as DUMMY.

4. DUMMY provides a safe way to eliminate I/O activity when required.

99
THE JOBLIB DD Statement

The JOBLIB DD statement identifies the program library where the


programs to be executed throughout the job reside
It must be placed between the JOB and the first EXEC statement

//TRG001A JOB 9927,HSBC,CLASS=7


//JOBLIB DD DSN=TRG.LIB.LOAD,DISP=SHR
// S1 EXEC PGM=PROGA
// S2 EXEC PGM=PROGB

Program PROGA is expected to reside in TRG.LIB.LOAD as a


member of a library and the system searches the directory. If not
found system will search certain predefined libraries. If it is still not
found S806 ABEND failure occurs.
A JOBLIB DD statement can have several concatenations (max:16)

100
THE JOBLIB DD Statement

//JOBLIB DD DSN=TEST.LOADLIB,DISP=SHR
// DD DSN=TEST.MYLIB,DISP=SHR
// DD DSN=PROD.LOADLIB,DISP=SHR

All concatenations may be searched to locate a program. If,


however, the program is found in a concatenation other than the
last one, other concatenations will not be used.

When duplicate member names exists in different concatenations,


the user can decide which one is to be executed by determining the
sequence of the concatenations.

101
THE STEPLIB DD Statement

The STEPLIB DD statement identifies the library where the


program to be executed for the step where STEPLIB is found
resides.

It can be placed anywhere.

//PROD213 JOB SH21, CLASS=P


//S1 EXEC PGM=PROGA
//STEPLIB DD DSN=TRG.LIB.LOAD1,DISP=SHR
//S2 EXEC PGM=PROGB
//STEPLIB DD DSN = TRG.LIB.LOAD2,DISP=SHR

Program PROGA is expected to reside in PROD.LOADLIB1 as a


member of the library.
If not found, default libraries are searched

102
THE STEPLIB DD Statement (Cont…)

//TRG001A JOB 9927,HSBC,CLASS=P…


//JOBLIB DD DSN=TRG.LIB.LOAD1,DISP=SHR
//S1 EXEC PGM=PROGA
//S2 EXEC PGM=PROGB
//STEPLIB DD DSN =TRG.LIB.LOAD2,DISP=SHR
//S3 EXEC PGM=PROGC

A STEPLIB DD statement has the effect of negating the JOBLIB DD


statement for a particular step

103
STORAGE DUMP

To request a storage dump, one of the following 3 DD statements


must be included in the step

- 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

Books for Reference

Expert MVS/XA JCL - Mani Carathanassis

MVS/JCL - Doug Lowe

106
JOB CONTROL LANGUAGE (JCL)

Thank You

107

You might also like