JCL Quick Reference
JCL Quick Reference
JCL Quick Reference
When technology complements business Copyright © 1987-2010 SimoTime Enterprises All Rights Reserved
Table of Contents Version 10.03.20
Introduction
JCL Statement Syntax
The Job Statement (or Job Card)
A Comment Statement
The EXEC Statement (or Defining a Job Step)
Defining Data Sets
The DD Statement for an Existing Data Set
The DD Statement for a New Data Set
Data Set Concatenation
Directing System Output
The DUMMY Data Set
Passing a Parameter to a Program
Passing a Parameter via PARM=
Passing a Parameter via SYSIN
JCL Procedures or PROC's
Instream Proc
JCL Substitution Parameters
The SET Statement
JCL INCLUDE and JCLLIB Statements
Specifying the Location of Programs
Conditional JCL
Summary
Software Agreement and Disclaimer
Downloads and Links to Similar Pages
Comments or Suggestions
About SimoTime
Introduction
(Next) (Previous) (Table-of-Contents)
Job Control Language (or JCL) specifies how programs are executed on the mainframe. JCL
functions are the interface between the programs and the operating system. Since JCL has the
ability to define data set names, parameters and system output devices the individual programs
can be flexible in their use because these items are not hard coded in the programs. Without the
need for re-compiling, the same program may be used to access different data sets and behave
differently based on parameters specified in JCL
JCL Statement Syntax
(Next) (Previous) (Table-of-Contents)
A JCL source member consists of a file of 80-byte, fixed-length records. The records (or JCL
statements) are written using positions 1-71. Position 72 is reserved for continuation, a space
character indicates no continuation and a non-space character indicates the next statement will be
a continuation of the current statement.. A JCL statement starts with two slashes in positions 1 to
2. The JCL specifies a jobname and can contain one or more steps. Each step will execute a
program or procedure (PROC). Comments statements may be added to the JCL using //* in
positions 1 to 3. Every JCL member must begin with a '"Job Card" that specifies the job name
and other information about how the job will execute. The JCL is completed by using '//' in
positions 1 and 2 or when the last statement is processed.
Every JCL member (or JOB) you write will require a JOB statement (or JOB card) to identify the
job. This must be the first statement in each job. Since the JOB card is a JCL statement it must
start with a '//' (two slashes) in positions 1-2. The following is a sample JOB statement.
....:....1....:....2....:....3....:....4....:....5....:....6....
:....7..
//SIMOJOB1 JOB (ACCTINFO),'comment',CLASS=A,MSGCLASS=0,
// MSGLEVEL=(1,1),NOTIFY=USERID
Note: The preceding JOB statement is continued across two statements. The length of the text is 72 bytes. Remember, a non-
space in position 72 indicates a continuation.
The job name should be in positions 3-n (for a maximum of eight characters) followed by a
space.
The job name is specified first, in this example the job name will be SIMOJOB1. The key-word
JOB is specified to indicate this is the JOB statement or Job Card.
The (ACCTINFO) is accounting information and is a required. This may be an accounting cost
center. The cost center information varies from site to site and may be used to do charge-backs to
individual departments for usage of the system.
The 'comment' is an identifying or explanatory field. It is optional but can very useful. It ha a 20
characters maximum length.
The job class is specified by using "CLASS=" key word. This information is used to tell the
system how the job is to be run. Jobs will be scheduled and will run under control of a predefined
class as determined by the job initiator. The job class may determine the priority of the job and
how long it will be allowed to run. If the job initiator is already running a job then the current job
request may be placed in a job queue and have to wait until the initiator is free.
The MSGCLASS=x is used to specify where the job output will be directed. The output classes
are predefined and vary from site to site. Two are the normal defaults are as follows.
A Normal system printing and all output listings sent to the default system printer.
0 Hold output in the queue and allow job output to be viewed on-line through the TSO outlist
facility.
y 0 The system prints only JCL messages. It prints JES and operator messages only if the
job abnormally terminates.
1 The system prints JCL messages and any JES and operator messages.
If you want to be notified when the job has finished then use the "NOTIFY=" key word. The
NOTIFY parameter must specify a valid userid.
A Comment Statement
(Next) (Previous) (Table-of-Contents)
A job step defines the program to run and is created by using the EXEC statement. There may be
one step or many steps within a job. The step name should be in positions 3-n (for a maximum of
eight characters) followed by a space. The following is an example of a JCL statement that
defines a step within a job and executes a program.
//STEPID01 EXEC PGM=IEFBR14
The preceding example defines the step name as STEPID01. The "EXEC" keyword identifies the
statement as a job step definition. The "PGM=" keyword and parameter specifies the program to
be executed. (i.e. EXECute ProGraM). The program to be executed is IEFBR14.
The preceding example defines the step name as STEPID02. The "EXEC" keyword identifies the
statement as a job step definition. The next parameter specifies the PROC (or procedure) to be
executed.
Defining the Data Sets used by a job step requires a Data Definition (or DD) statement. A simple
DD statement requires a DDNAME, a Data Set Name (or DSN) and a Disposition (or DISP)
keyword.
In the preceding example the ddname in the JCL DD statement corresponds to the name used in
the COBOL SELECT statement. The DSN= keyword and parameter specifies the fully-qualified
MVS Data Set Name. The DISP= keyword and parameter specifies the disposition as follows.
DISPostion
Description
status
OLD The dataset exists and this job step has exclusive use of the dataset.
SHR The dataset exists and other users and jobs can access the dataset,
this is the default
MOD The dataset should be kept and new records will be appended to the
end of the dataset. The dataset may or may not exist. If it does not
exist then a data set will be created.
NEW The dataset does not exist and will be created.
normal-termination-disp Description
DELETE Deletes the data set at the end of the step
KEEP Keeps the data set.
CATLG Places the entry in the system catalog or user catalog. For a NEW
data set this is the default.
UNCATLG Deletes the entry from the system catalog or user catalog.
abnormal-termination-disp Description
DELETE Indicates that the data set is to be deleted at the end of a job step.
KEEP Indicates that the data set is to be kept.
CATLG Indicates that the system should place an entry in the system or user
catalog.
UNCATLG Indicates that the system is to delete the entry in the system or user
catalog.
The DD name should be in positions 3-n (for a maximum of eight characters) followed by a
space. The DDNAME should correspond to the name defined in the program. For example, with
COBOL the name defined by the ASSIGN clause of the SELECT statement. The following is an
example of a DD statement followed by a COBOL SELECT statement with an ASSIGN clause.
In the preceding example the COBOL program will read QSAM0080 and the DD statement will
map to the file specified in the DSN parameter (SIMOTIME.DATA.QSAM0080).
The following is an example and will vary at each mainframe location depending on the system
hardware and software configuration. The important items on the following is the DISP and
DCB information.
//SQADB512 DD DSN=SIMOTIME.DATA.SQADB512,DISP=(NEW,CATLG,DELETE),
// STORCLAS=MFI,
// SPACE=(TRK,5),
// DCB=(RECFM=FB,LRECL=512,BLKSIZE=5120,DSORG=PS)
DISPostion Description
NEW Specifies a new data set.
CATLG Create a new catalog entry.
DELETE If request abnormally terminates then delete the data set if it exist.
DCB Description
RECFM Record Format, in this example the record format is Fixed Block (FB).
LRECL Record Length.
BLKSIZE Block Size.
DSORG Data Set Organization.
It is possible to process more than one data set as a single data set by concatenating the DD
statements.
//QSAM0080 DD DSN=SIMOTIME.DATA.FILE0001,DISP=SHR
// DD DSN=SIMOTIME.DATA.FILE0002,DISP=SHR
// DD DSN=SIMOTIME.DATA.FILE0003,DISP=SHR
SELECT QSAM0080-FILE
ASSIGN to QSAM0080
ORGANIZATION is SEQUENTIAL
ACCESS MODE is SEQUENTIAL
FILE STATUS is QSAM0080-STATUS.
In the preceding example the COBOL program will read QSAM0080 and the DD statements will
map the three files (FILE0001, FILE0002 and FILE0003) as one file. The program's initial read
will get the first record from FILE0001 and will not get an End-of-File condition until the last
record of FILE0003 is processed.
The DD statement with a SYSOUT parameter is used to assign an output class to an output data
set. The form of this parameter is:
//REPORT1 DD SYSOUT=A
//REPORT2 DD SYSOUT=*
In the preceding example the REPORT1 output will be directed to SYSOUT=A which is usually
the system printer. The REPORT2 output will be directed to the location specified in the
MSGCLASS of the JOB statement. If MSGCLASS=0 then REPORT2 output will be directed to
SYSOUT=0 which is usually placed in the JES Output Queue for a specified period of time
(such as 3 days) before being purged.
if the ddname is SYSOUT (i.e. //SYSOUT ...) and SYSOUT=* then the job class will be the same
as that specified in the MSGCLASS in the job statement. Since the ddname is SYSOUT the
DISPLAY in a COBOL program will be directed to the location specified in the MSGCLASS of
the JOB statement. If MSGCLASS=0 then REPORT2 output will be directed to SYSOUT=0
which is usually placed in the JES Output Queue for a specified period of time (such as 3 days)
before being purged. The following is a sample JCL statement with SYSOUT as the DD name.
//SYSOUT DD SYSOUT=*
In the preceding example the text string "This is a test..." will be routed to the JES output queue.
The use a a DD statement with a DUMMY parameter will allow a program to run if a data set
does not exist. The following example show a DD DUMMY statement.
//QSAM0080 DD DUMMY
SELECT QSAM0080-FILE
ASSIGN to QSAM0080
ORGANIZATION is SEQUENTIAL
ACCESS MODE is SEQUENTIAL
FILE STATUS is QSAM0080-STATUS.
The following shows the COBOL statements for the open, read and close of the QSAM0080 data
set (i.e. sequential file).
In the preceding example the OPEN will be successful, the first READ will return an End-of-File
return code and the close will be successful.
Passing a Parameter to a Program
(Next) (Previous) (Table-of-Contents)
The two techniques use to pass information (a Parameter) from JCL to a program are as follows.
Technique Description
via This technique uses a PARM=parameter keyword on the EXEC statement in JCL.
PARM= The COBOL program requires a LINKAGE SECTION.
via SYSIN This technique requires SYSIN statement followed by the parameter to be placed in
the JCL. The COBOL program requires an "ACCEPT parameter from SYSIN" to be
coded in the COBOL program. If the SYSIN statement is missing in the JCL the
ACCEPT will ABEND with a "File not found" message. To avoid this it will be
necessary to use a "//SYSIN DD DUMMY" statement in the JCL when a parameter
is not being passed.
The following two section describe parameter-passing in more detail. Simply click on one of the
following items to learn more or download a set of sample programs that describe how to pass a
parameter string from JCL to a COBOL program.
To pass a parameter from JCL to a program requires the use of the "PARM=" keyword with the
EXEC statement. The following JCL statement shows an EXEC statement without a parameter
defined.
//* *******************************************************************
//* Step 1 of 2, Execute the COBOL program without a parameter.
//*
//CBLPARS1 EXEC PGM=CBLPARC1
The following JCL statement shows an EXEC statement with a parameter defined by using the
"PARM=" keyword. Notice the comma immediately after the program name. The parameter
following the "PARM=" keyword requires the apostrophes if the text string contains space
characters.
//* *******************************************************************
//* Step 2 of 2, Execute the COBOL program with a parameter.
//*
//CBLPARS2 EXEC PGM=CBLPARC1,
// PARM='SimoTime, When technology complements business'
//* *******************************************************************
//* Step 1 of 2, Execute the COBOL program without a parameter.
//*
//SYSIN DD DUMMY
The following JCL statements show what is required to pass information via SYSIN.
//* *******************************************************************
//* Step 2 of 2, Execute the COBOL program with a parameter.
//*
//SYSIN DD *
Parameter from SYSIN...
//*
JCL defines how a job is executed on the mainframe. A job may perform many steps or execute
many programs in order to produce the requested information or output. If a segment of JCL is
used repeatedly it may be coded once as a PROC (or JCL Procedure) and then used by many
different steps within the job. There are two approaches to defining and using PROC's.
Instream Proc
(Next) (Previous) (Table-of-Contents)
The following is an example of an instream PROC that is used three times when the JOB is
executed. The job step that calls the instream PROC will provide the name of the PDS to be
created via the &DSNAME substitution value.
Additional information about the use of JCL and PROCs may be found in the JCLPRC01.HTM
document.
JCL substitution is mainly used when a repeatable process is used many times but needs the
ability to behave differently based on variable information passed from the job that is excuting
the process. Simply click on one of the following items to learn more or download sample JCL
that describe how to use variable substitution within JCL.
The SET statement lets you set the values of symbolic parameters within a JCL or PROC
member. Simply click on one of the following items to learn more or download sample JCL that
describes the SET statement.
20 //*
21 //* *******************************************************************
22 //*
23 // JCLLIB ORDER=SIMOTIME.PDS.JCLINC
24 // INCLUDE MEMBER=JCLINCI1
##*
##* *******************************************************************
##* SET Values from the JCLINCI1.INC Member.
## SET HLQ01=SIMOTEST
## SET HLQ02=TEMP
25 //* *******************************************************************
26 //* Step 1 of 2 This job step will delete a previously created
27 //* hex-dump file.
28 //*
29 //TAKEAWAY EXEC PGM=IEFBR14
30 //TESTFILE DD DSN=&HLQ01..&HLQ02..TESTFILE,DISP=(MOD,DELETE,DELETE),
SUBSTITUTION - DSN=SIMOTEST.TEMP.TESTFILE,DISP=(MOD,DELETE,DELETE),
31 // STORCLAS=MFI,
32 // SPACE=(TRK,5),
33 // DCB=(RECFM=V,LRECL=80,DSORG=PS)
34 //*
Simply click on one of the following items to learn more or download a sample set of programs.
If programs are not stored in the libraries predefined for the operating systems then it will be
necessary to specify the location of the programs. For example, if program are located in a
private library or a test library then use STEPLIB and/or JOBLIB to tell the system the location
of the programs.
STEPLIB and JOBLIB require a DD statement that defines the names of the Load Libraries that
are searched to find and load the program. As the names imply the STEPLIB statement applies
only to an individual job step, the JOBLIB statement applies to the whole job. If you specify
both then the STEPLIB statement will override what is specified by the JOBLIB statement but
only for the individual step.
A JOBLIB statement must be specified after the Job statement and before any job steps (or
EXEC statements). The STEPLIB must be specified after the EXEC PGM statement of the job
step.
Conditional JCL
(Next) (Previous) (Table-of-Contents)
This suite of programs provides an example of how mainframe JCL can do conditional
processing. The first JCL example will focus on the approaches used by JES/2 using the
"COND=" parameter on the JOB or EXEC statement. With JES/3 the conditional processing was
improved to use "IF" statements. The second JCL example will focus on the IF, THEN, ELSE
and ENDIF statement construct. Both JCL examples accomplish the same task. However, the
second JCL example has additional information displayed when there is a difference between the
actual and expected return code. The use of the COND parameter can be very difficult to code
and understand. I would recommend the use of the IF, THEN, ELSE and ENDIF statement
construct if you have a choice.
Simply click on one of the following items to learn more or download a set of sample programs
that describe how to use conditional JCL.
Summary
(Next) (Previous) (Table-of-Contents)
The purpose of this document is to assist as a tutorial for new programmers or as a quick
reference for experienced programmers. In the world of programming there are many ways to
solve a problem. This suite of programs is provided as a possible quick reference for IBM
Mainframe Job Control Language (or JCL).
Permission to use, copy, modify and distribute this software for any commercial purpose requires
a fee to be paid to SimoTime Enterprises. Once the fee is received by SimoTime the latest
version of the software will be delivered and a license will be granted for use within an
enterprise, provided the SimoTime copyright notice appear on all copies of the software. The
SimoTime name or Logo may not be used in any advertising or publicity pertaining to the use of
the software without the written permission of SimoTime Enterprises.
Permission to use, copy, modify and distribute this software for a non-commercial purpose and
without fee is hereby granted, provided the SimoTime copyright notice appear on all copies of
the software. The SimoTime name or Logo may not be used in any advertising or publicity
pertaining to the use of the software without the written permission of SimoTime Enterprises.
SimoTime Enterprises makes no warranty or representations about the suitability of the software
for any purpose. It is provided "AS IS" without any express or implied warranty, including the
implied warranties of merchantability, fitness for a particular purpose and non-infringement.
SimoTime Enterprises shall not be liable for any direct, indirect, special or consequential
damages resulting from the loss of use, data or projects, whether in an action of contract or tort,
arising out of or in connection with the use or performance of this software.
If you have any questions, suggestions or comments please call or send an e-mail to:
[email protected]
Note: You must be attached to the Internet to download a Z-Pack or view the list.
Check out The JCL Connection for more mainframe JCL examples.
Check out The COBOL Connection for more examples of mainframe COBOL coding
techniques and sample code. Also, take a look at a simple example of parameter passing
between JCL and COBOL.
Check out The SimoTime Library for a wide range of topics for Programmers, Project
Managers and Software Developers.
To review all the information available on this site start at The SimoTime Home Page .
Comments or Suggestions
(Next) (Previous) (Table-of-Contents)
If you have any questions, suggestions or comments please call or send an e-mail to:
[email protected].
About SimoTime Enterprises
(Next) (Previous) (Table-of-Contents)
Return-to-Top
Copyright © 1987-2010 SimoTime Enterprises All Rights Reserved
When technology complements business
http://www.simotime.com
Version 03.04.11