Introduction To JCL: JCL (Job Control Language)
Introduction To JCL: JCL (Job Control Language)
Introduction to JCL
JCL (Job Control Language) is one of the old and most robust scripting language that work as a
communication between program (COBOL or Assembler) and the operating system (Mainframe; OS
Z).
JCL widely used in Batch Scheduling where different aspects of Batch processing are fed into JCL
which is in turn received by operating system.
Job Processing
A job is a unit of work which can be made up of many job steps. Each job step is specified in a Job
Control Language (JCL) through a set of Job Control Statements.
The Operating System uses Job Entry System (JES) to receive jobs into the Operating System, to
schedule them for processing and to control the output.
Input
Conversion
Processing
Output (Spool / Print)
Purge
JOB Statement is the first control statement in a JCL. This gives the identity of the job to the
Operating System (OS), in the spool and in the scheduler. The parameters in the JOB statement help
the Operating Systems in allocating the right scheduler, required CPU time and issuing notifications
to the user.
Syntax
Description
Let us see the description of the terms used in above JOB statement syntax.
Job-name
This gives an id to the job while submitting it to the OS. It is can be length of 1 to 8 with
alphanumeric characters and starts just after //.
JOB
Positional-param
This refers to the person or group to which the CPU time is owed. It is
set as per the rules of the company owning the mainframes. If it is
Account information
specified as (*), then it takes the id of the user, who has currently
logged into the Mainframe Terminal.
This identifies the person or group, who is in charge of the JCL. This is
Programmer name
not a mandatory parameter and can be replaced by a comma.
Keyword-param
Following are the various keyword parameters, which can be used in JOB statement. You can use
one or more parameters based on requirements and they are separated by comma:
CLASS=0 to 9 | A to Z
PRTY To specify the priority of the job within a job class. If this parameter is
not specified, then the job is added to the end of the queue in the
specified CLASS. Following is the syntax:
PRTY=N
NOTIFY="userid | &SYSUID"
NOTIFY
Here system sends the message to the user "userid" but if we use
NOTIFY = &SYSUID, then the message is sent to the user submitting
the JCL.
To specify the output destination for the system and Job messages
when the job is complete. Following is the syntax:
MSGCLASS=CLASS
MSGCLASS
Valid values of CLASS can be from "A" to "Z" and "0" to "9". MSGCLASS
= Y can be set as a class to send the job log to the JMR (JOBLOG
Management and Retrieval: a repository within mainframes to store
the job statistics).
MSGLEVEL=(ST, MSG)
TYPRUN Specifies a special processing for the job. Following is the syntax:
Specifies the address space required to run a job step within the job.
Following is the syntax:
REGION=nK | nM
Example
// MSGCLASS=X,MSGLEVEL=(1,1),TYPRUN=SCAN,
// TIME=(3,0),REGION=10K
Here, JOB statement is getting extended beyond the 70th position in a line,so we continue in the
next line which should start with "//" followed by one or more spaces.
Miscellaneous Parameters
There are few other parameters, which can be used with JOB Statement but they are not frequently
used:
BYTES Size of data to be written to output log and the action to be taken
when the size is exceeded.
These are used in conditional job step processing and are explained
COND and RESTART
in detail while discussing conditional Processing.
Each JCL can be made of many job steps. Each job step can execute a program directly or can call a
procedure, which in turn executes one or more programs (job steps). The statement, which holds
the job step program/procedure information is the EXEC statement.
The purpose of the EXEC statement is to provide required information for the program/procedure
executed in the job step. Parameters coded in this statement can pass data to the program in
execution, can override certain parameters of JOB statement and can pass parameters to the
procedure if the EXEC statement calls a procedure instead of directly executing a program.
Syntax
Description
Let us see the description of the terms used in above EXEC statement syntax.
STEP-NAME
This identifies the job step within the JCL. It can be of length 1 to 8 with alphanumeric characters.
EXEC
POSITIONAL-PARAM
PGM This refers to the program name to be executed in the job step.
This refers to the procedure name to be executed in the job step.
PROC
We will discuss it a separate chapter.
KEYWORD-PARAM
Following are the various keyword parameters for EXEC statement. You can use one or more
parameters based on requirements and they are separated by comma:
This is used to specify whether the job step require virtual or real
storage for execution. Virtual storage is pageable whereas real
storage is not and is placed in the main memory for execution.
ADDRSPC Job steps, which require faster execution can be placed in real
storage. Following is the syntax:
ADDRSPC=VIRT | REAL
When an ADDRSPC is not coded, VIRT is the default one.
Example
Following is a simple example of JCL script along with JOB and EXEC statements:
// NOTIFY=&SYSUID
//*
// ACCT=(XXXX),REGION=8K,ADDRSPC=REAL,TIME=1440
JCL - DD Statement
Datasets are mainframe files with records organised in a specific format. Datasets are stored on the
Direct Access Storage Device (DASD) or Tapes of the mainframe and are basic data storage areas. If
these data are required to be used/created in a batch program, then the file (i.e., dataset) physical
name along with the file format and organisation are coded in a JCL.
The definition of each dataset used in the JCL is given using the DD statement. The input and output
resources required by a job step needs to be described within a DD statement with information such
as the dataset organisation, storage requirements and record length.
Syntax
//DD-name DD Parameters
Description
Let us see the description of the terms used in above DD statement syntax.
DD-NAME
A DD-NAME identifies the dataset or input/output resource. If this is an input/output file used by a
COBOL/Assembler program, then the file is referenced by this name within the program.
DD
PARAMETERS
Following are the various parameters for DD statement. You can use one or more parameters based
on requirements and they are separated by comma:
Parameter Description
DISP The DISP parameter is used to describe the status of the dataset,
disposition at the end of the job step on normal and abnormal
completion. DISP is not required in a DD statement only when the
dataset gets created and deleted in the same job step (like the
temporary datasets). Following is the syntax:
DISP=(status, normal-disposition, abnormal-disposition)
Following are valid values for status:
NEW : The dataset is newly created by the job step. OUTPUT1 in the
example above.
OLD : The dataset is already created and will be overwritten in the job
step. The job step gains exclusive access on the dataset and no other
job can access this dataset until the completion of the job step.
SHR : The dataset is already created and will be read in the job step.
The dataset can be read by multiple jobs at the same time. Example:
INPUT1 and INPUT2.
MOD : The dataset is already created. This disposition will be used
when there is a need to append new records to the existing dataset
(existing records will not be overwritten).
A normal-disposition parameter can take one of the following values
CATLG, UNCATLG, DELETE, PASS and KEEP
A abnormal-disposition parameter can take one of the following
values
CATLG, UNCATLG, DELETE and KEEP
Here is the description of CATLG, UNCATLG, DELETE, PASS and KEEP
parameters:
CATLG : The dataset is retained with a entry in the system catalog.
UNCATLG : The dataset is retained but system catalog entry is
removed.
KEEP : The dataset is retained without changing any of the catalog
entries. KEEP is the only valid disposition for VSAM files. This is to be
used only for permanent datasets.
DELETE : Dataset is deleted from user and system catalog.
PASS : This is valid only for normal disposition. This is used when the
dataset is to be passed and processed by the next job step in a JCL
When any of the sub-parameters of DISP are not specified, the default
values are as follows:
status : NEW is the default value.
normal-disposition : If status is NEW, default normal-disposition is
DELETE, else it is KEEP.
abnormal-disposition : Same as normal disposition.
SPACE The SPACE parameter specifies the space required for the dataset in
the DASD (Direct Access Storage Disk). Following is the syntax:
SPACE=(spcunits, (pri, sec, dir), RLSE)
Here is the description of all the used parameters:
spcunits : This can be one of the CYL(Cylinder), TRK(Tracks) or
BLKSIZE(Block Size).
pri : This is the primary space required for the dataset.
sec : This is the additional space required, when the primary space is
not being sufficient.
ir : This is the directory blocks required, if the dataset is a PDS
(Partitioned Dataset) with members within it.
RLSE : This is used to release the unused space at job completion.
The UNIT and VOL parameters are listed in the system catalog for
catalogued datasets and hence can be accessed with just the physical
DSN name. But for uncataloged datasets, the DD statement should
include these parameters. For new datasets to be created, the
UNIT/VOL parameters can be specified or the Z/OS allocates the
suitable device and volume.
UNIT The UNIT parameter specifies the type of device on which the dataset
is stored. The device type can be identified using Hardware Address or
Device type group. Following is the syntax:
UNIT=DASD | SYSDA
Where DASD stands for Direct Access Storage Device and SYSDA
stands for System Direct Access and refers to the next available disk
storage device.
Following is an example, which makes use of DD statements along with various parameters
explained above:
// NOTIFY=&SYSUID
//*
//STEP010 EXEC PGM=ICETOOL,ADDRSPC=REAL
//*
//INPUT1 DD DSN=TUTO.SORT.INPUT1,DISP=SHR
//INPUT2 DD DSN=TUTO.SORT.INPUT2,DISP=SHR,UNIT=SYSDA,
// VOL=SER=(1243,1244)
//OUTPUT1 DD DSN=MYFILES.SAMPLE.OUTPUT1,DISP=(,CATLG,DELETE),
// RECFM=FB,LRECL=80,SPACE=(CYL,(10,20))
//OUTPUT2 DD SYSOUT=*