Mainframe-JCL

24 views
Skip to first unread message

ajay tated

unread,
Oct 14, 2011, 12:32:07 PM10/14/11
to BE CSE2, JNEC
Introduction To JCL
JCL (Job Control Language)
• Job Control Language is used to tell the system what program(COBOL
program) to execute followed by description of program’s inputs and
outputs.
• JCL consists of control statements that :
o Introduce computer job (i.e. COBOL program) to operating system.
o Request hardware devices
o Direct the Operating System on what is to be done in terms of
running applications and scheduling resources.
• JCL provides the means of communication between an application
program and the operating system and computer hardware.
• Since programmer defines data set name, parameters and system output
devices, used by program, in JCL, so without recompiling the program
programmer can change data set name if after some time program needs
to refer some other data set or location of data set changes.







• From this diagram, COBOL program doesn’t refer to the actual
physical data set. Here, program has written one program in JCL to
refer physical data set which is going to be used in COBOL program.
• In batch mode, when there is need to execute multiple programs then,
all those programs can be written in single JCL so, programmer doesn’t
need to execute each program separately. He can just execute single
JCL which will eventually execute all programs mentioned in it.
• After Compilation, COBOL programs is translated into binary machine
language. These machine language programs are stored as members of
Partitioned Dataset (PDS).
• The PDS whose members are such machine language programs is called
Load Module Library and each binary program or member is called as
Load Module.
• To execute a COBOL program, programmer needs to specify load module
in JCL.
• Following diagram shows few related actions with JCL :
• Few keywords from diagram :
o Job : Cobol Program
o JES (Job Entry Subsystem)
 Receives the job into OS
 Schedules them for processing by Z/OS
 Controls their output processing







Structure of JCL
• There are 8 different JCL statements.
• Following statements are used most often-
o JOB
o EXEC
o DD
• Statements to pack JCLs into procedure
o PROC
o APEND
• Optional statements are
o //* - Comment
o /* - Delimiter
o // - Null ending statement
JOB Statement
• Every JCL begins with a JOB statement. The JOB statement establishes
the identity of the job.
• It conveys a lot of extra information about the job.
• Syntax for JOB statement is:
// name JOB parameters…
• Here name is that programmer assigns to the JOB statement.
• Other parameters are as follows :
o Accounting Information : Information about programmer’s account
against which bill needs to be generated for amount of time programmer
has used computer system.
o It is given as,
// MYJOB JOB (A123, ‘PAK’)
Here, A123 is account number and PAK is the name of account holder.
Specifying name of account holder is optional.

o Labeling and routing information : As Job (COBOL program called
through JCL), runs OS generates status messages about the job run.
o Programmer can specify labeling field in the JOB statement which is
displayed when status messages are printed on each of the separator
pages or screens.
o Labeling information is given as,
//MYJOB JOB A123 , ‘TEST CODE’
Here, TEST CODE text will be displayed on each page of status
messages.

After these parameters, rest of all parameters are keyword parameters
which can appear in any order. Keyword parameters are identified by
writing keyword.

o CLASS: This parameter is used to specify category of the job.
Category in terms of required execution time for job.
o For e.g. CLASS = A for small jobs, CLASS = G for medium jobs, CLASS
= R for long-running jobs. These categories are decided by system
programmers.
o This categorization helps the OS to easily pick up a job for
execution.
o CLASS is given as,
//MYJOB JOB A123, ‘TEST CODE’, CLASS = A

o PRTY: This parameter is related to CLASS parameter. It assigns
priority to jobs which belong to the same class.
o Higher value of priority takes precedence over the job with lower
value.
o Consider, two jobs belong to Class ‘A’ with priorities 12 and 5.
Then, job with priority 12 will run before job with priority 5.
o Valid values for priority is between 0 to 15.
o PRTY is given as,
//MYJOB JOB A123, ‘TEST CODE’, CLASS = A, PRTY = 6.

o MSGCLASS: In this parameter, programmer can specify the output
device to which system generated status messages or JCL output
messages are written.
o System programmers decide different codes for different output
devices.
//MYJOB JOB A123, ‘TEST CODE’, CLASS = A, PRTY = 6, MSGCLASS = A
Consider code ‘A’ is used for printer.

o MSGLEVEL: With this parameter programmer can specify how much level
of detail information should be printed in the log-report. Or should
be printed on the device which is specified in MSGCLASS parameter.
o Syntax for MSGLEVEL is : MSGLEVEL = (statements, messages)
o Statement :
 0 - Information related to JOB statement only
 1 – Complete JCL should be printed
 2 – Only the input JCL statements being printed
o Messages:
 0 – Allocation or termination messages will be printed if job
terminated abnormally
 1- Allocation or termination messages will be printed regardless of
whether job is terminated normally or abnormally.
o By default value for MSGLEVEL = (1, 1)
o JOB statement will be,
//MYJOB JOB A123, ‘TEST CODE’, CLASS = A, PRTY = 6, MSGCLASS = A,
MSGLEVEL = (1,0)

o TYPRUN: This parameter is used to specify whether job is to be held
until further notice or for syntax checking.
o Two value for TYPRUN are either HOLD or SCAN.
o JOB statement will be,
//MYJOB JOB A123, ‘TEST CODE’, CLASS = A, PRTY = 6, MSGCLASS = A,
MSGLEVEL = (1,0) TYPRUN = SCAN

o NOTIFY: NOTIFY parameter is used to direct the system where it has
to send the success/failure message after completing the job.
o Syntax for NOTIFY is, NOTIFY = userid or &SYSID.
o NOTIFY = userid – it is for any specific user.
o NOTIFY = &SYSID - it is for user who has submitted a job.
o JOB statement will be,
//MYJOB JOB A123, ‘TEST CODE’, CLASS = A, PRTY = 6, MSGCLASS = A,
MSGLEVEL = (1,0) TYPRUN = SCAN, NOTIFY = &SYSUID
EXEC Statement
• In this JCL statement name of a program to be executed is specified.
• Syntax is :
// name of statement EXEC parameters….
• Example of EXEC statement:
// STEP1 EXEC PGM = MYPRM
• Like other JCL statements, an EXEC statement has got to begin with
name. Programmer can assign a name upto eight characters with the
first letter as an alphabet. In give example, STEP1 is name of EXEC
statement.
• PGM parameter : In this parameter programmer has to specify name of
load module which is to be executed through JCL program.
• Load module which need to be run is stored as a member of
Partitioned Dataset (PDS). A partitioned dataset that contains load
modules is called Load Library.
• Whatever load module programmer has specified in PGM parameter,
Operating System first tries to find this module in system’s
predefined library i.e. SYS1.LINKLIB, considering specified program is
IBM provided one.
• But, if programmer needs to execute some user written programs then,
directory or load library needs to be specified where that load module
is stored.
• This load library or directory can be specified using JOBLIB or
STEPLIB statements. Both these statements are DD type statements. (DD
statement is explained in next topic)
• Syntax for JOBLIB and STEPLIB:
//STEPLIB DD DSN = path of directory DISP = SHR
//JOBLIB DD DSN = path of directory DISP = SHR
• JOBLIB statement : Whatever directory we specify in JOBLIB that is
applicable to all statements in JCL.
• Example,
//MYJOB JOB A123
//JOBLIB DD DSN = BE.TEST DISP = SHR
//STEP1 EXEC PGM = COBPROG
//STEP2 EXEC PGM = PROG
• In this example, both modules specified in STEP1 and STEP2 will be
present in BE.TEST. If there will be next EXEC statement then, module
in that statement will also be found at BE.TEST. This means, whatever
specified in JOBLIB is applicable to all programs in all EXEC
statements present in JCL.
• STEPLIB statement : It is also has same purpose as JOBLIB. But,
whatever value specified in STEPLIB is only applicable to single step
(statement) instead of entire JCL program.
• Example,
//MYJOB JOB A123
//STEP1 EXEC PGM= COBPROG
//STEPLIB DD DSN = BE.TEST, DISP = SHR
//STEP2 EXEC PGM= COBPROG1
//STEPLIB DD DSN = BE.TEST1, DISP = SHR
• In this example, STEP1 is executing COBPROG which is member of
BE.TEST while, COBPROG1 in STEP2 is member of BE.TEST1.
• Note : If JOBLIB and STEPLIB are coded together then, the STEPLIB
specification will override JOBLIB specification.
• Other EXEC parameters are:
o ACCT : Similar to JOB statement, accounting information is provided
with this parameter. So, bill for time required to execute program
specified in EXEC, will be generated against account number specified
in ACCT parameter.
o EXEC statement will be,
//STEP1 EXEC PGM = PROGRAM1, ACCT = A123

o PARM : The PARM parameter is used to pass the input values to the
program being executed.
o EXEC statement will be,
//STEP1 EXEC PGM = PROGRAM1, ACCT = A123, PARM = RAM
To access this parameter LINKAGE SECTION needs to be used in COBOL
program.

o DPRTY : DPRTY parameter assigns dispatching priority to a particular
job-step (means EXEC statement in which Cobol program is mentioned to
execute)
o Format for DPRTY is, DPRTY = (value1, value2)
o Actual value is calculated as, 16* value1 + value2
o EXEC statement will be,
//STEP1 EXEC PGM = PROGRAM1, ACCT = A123, PARM = RAM, DPRTY = (5,6)
//STEP2 EXEC PGM = PROGRAM2, ACCT = A123, PARM = RAM, DPRTY = (6,5)
o DPRTY value for STEP2 is, 86 and for STEP1 is 101 so, STEP1 will be
executed first.

o PERFORM: Different tasks, jobs executed by Operating system are
divided into different Performance groups depending on their access
speed to memory, CPU cycles need to execute that task etc.
o So, depending on execution of program specified in EXEC statement it
can be classify in some performance group. In PERFORM parameter
programmer have to specify performance group value.
o Values for performance groups are defined by system programmer.
o EXEC statement will be,
//STEP1 EXEC PGM = PROGRAM1, ACCT = A123, PARM = RAM, DPRTY = (5,6),
PERFORM = 15.

There are few common parameters on JOB and EXEC statements. Such
parameters are discussed below:
o REGION: This parameter specifies an upper bound on the amount of
storage space that a batch job or job-step (specified Cobol program
execution) will require.
o Programmer specifies REGION parameter on JOB statement if programmer
wants to specify a space constraint for entire JCL program.
e.g. //MYJOB JOB A123, REGION = 4M
o Programmer specifies REGION parameter on EXEC statement if
programmer wants to specify space constraint only on a particular job-
step.
e.g. //STEP1 EXEC PGM = PROGRAM1 REGION = 2K

o COND: The COND parameter is used for conditional execution. It is
used to control flow of execution.
o If condition specified in COND parameter is true then, the
subsequent statement is not executed.
o Syntax for COND parameter is : COND = (CODE, OPERATOR, STEPNAME)
o CODE value can be any value between 0 to 4095.
o OPERATOR can be GT, LT, GE, LE, EQ, NE.
o STEPNAME is optional.
o Operating System while executing each job step of JCL returns some
status code. And that status code value is checked with the value
specified as a code in COND parameter.
o If STEPNAME is given then return code of that particular step is
checked in COND parameter.
o But, If STEPNAME is not given then the return codes of all previous
steps are checked.
o E.g. //STEP2 EXEC PGM = PRM1, COND = (4, GT, STEP1)
In this example, STEP2 is bypassed or not executed iff, 4 is greater
than return code of STEP1.
DD Statement
• Every program specified using PGM parameter in EXEC statement is
executed. This program takes input data and generates output data.
• The input data is read from input dataset. The output data is
generated and put into or stored in the output dataset.
• These input and output datasets are specified using DD statements.
Data sets can be temporary or permanent. Temporary datasets are
created and deleted within the job execution whereas permanent
datasets are retained.
• Different parameters in DD statement are as discussed below:
o DSN: This parameter is used to specify name of the dataset.
o E.g. //INDD DD DSN = BE.TEST.INPUT
//OUTDD DD DSN = BE.TEST.OUTPUT
o Here, data set of BE.TEST.INPUT is referred by INDD. INDD is nothing
but the name of DD statement. In Cobol program if there is any need to
refer INPUT dataset then it will be referred using INDD.

o DISP: DISP parameter is used to specify the disposition of a
dataset. Disposition means what to do with datasets once the Cobol
program is executed either successfully or abnormally.
o Syntax for DISP parameter is :
DISP = (current_status, normal_disposition, abnormal_disposition)
o Current_status : current status indicates whether dataset is to be
created newly or it preexists. If the dataset already exists, then do
we need to only read from the dataset or modify the dataset.
o The current_status can take any of the following options:
 NEW : NEW is used when data set has to be newly created. E.g.
DISP=NEW
 OLD : OLD is used when the data set already exists. When DISP = OLD
is used it reserves the dataset no other batch job can use the
dataset.
 SHR: It permits old dataset to be shared. It is identical to OLD
except that several batch jobs can read the dataset concurrently.
 MOD : Generally, when there is need to append data to the end of
existing sequential dataset then, DISP = MOD is used.
o Normal_disposition : This parameter is used when a program specified
in EXEC statement is executed successfully. Normal_disposition
parameter can take following options:
 DELETE : The dataset must be deleted after execution.
 CATLG : The dataset must be cataloged.
 UNCATLG : The dataset must be removed from catalog.
 KEEP : It is used to specify that dataset must be retained.
 PASS : The dataset must be passed to subsequent job step (EXEC
statement).
o Abnormal_disposition : This parameter is used when a program
specified in EXEC statement is terminated abnormally. It can take
following options (same as normal_disposition) : DELETE, CATLG,
UNCATLG, KEEP

System catalog is special dataset that stores the name of the dataset,
followed by the volume of device on which it is stored. Datasets whose
location has been recorded in the system catalog are called cataloged
dataset. Datasets whose location has not been mentioned in the system
catalog are called uncataloged dataset.
If there are uncataloged dataset need to be used then, location of
that dataset must be specified manually using parameters UNIT and VOL.

o UNIT: UNIT parameter can be used to identify a device, by the device
address or by symbolic name.
o E.g. // INDD DD DSN = BE.INPUT, DISP = SHR, UNIT = SYSDA
o This means, that the input dataset BE.INPUT is located on the device
group whose symbolic name is SYSDA.

o VOL: VOL parameter is used to specify disk volume on which the
dataset resides. (If there are more than one same type of devices then
each device is called as a volume.) VOL parameter has several sub
parameters as :

 SER : Specifies serial number of a device.
 PRIVATE : Allows access to this disk volume by only single user.
 RETAIN : Prevents volume from being dismounted till the program
execution ends.
 E.g. //INDD DD DSN = BE.INPUT, DISP = SHR, VOL = (SER = T02947,
RETAIN, )
In this example, dataset is present on device with serial number
T02947 and this volume is not private and it will not be dismounted
until the program execution ends.

JCL PROC (Procedure)
• In JCL also we have an important concept of re-usability in the form
of Instream and Cataloged procedures.
• Once a JCL is written we can give it a name, and make it available
for others. A third person who requires the same functionality can
simply call pre-written JCL and use it as ready-made object.
• Cataloged Procedure:
o Example of JCL procedure is:
//MYPROC PROC
//STEP1 EXEC PGM = COPRG1
//STEP2 EXEC PGM = COPRG2
//PEND
o This procedure can be saved either in a user-defined library or
default system library. Default library is SYS1.PROLIB.
o To call procedure,
//MYJOB JOB A123
//STEP1 EXEC PROC = MYPROC
o Here, while executing MYPROC, it will be first searched in any user-
defined library (if specified). If it is not specified then procedure
is searched in default library i.e. SYS1.PROLIB.
o To specify user-define library where procedure is stored JCLLIB
statement as follows,
//MYJOB JOB A123
// JCLLIB ORDER = (BE.TEST)
//STEP1 EXEC PROC = MYPROC
o This is same as programmer needs to import package while writing
Java program.


• Instream Procedure :
o Instream procedure is a PROC written as a part of the same JCL and
referred elsewhere in the JCL.
o E.g.
//MYJOB JOB A123
//MYINPROC PROC
//PSTEP1 EXEC PGM = PROGRAM1
//PSTEP2 EXEC PGM = PROGRAM2
// PEND
//STEP1 EXEC PGM = SAMPLE1
//STEP2 DD PROC = MYINPROC
o Maximum number of instream procedures written in JCL is 15.























Reply all
Reply to author
Forward
0 new messages