JCL Quick Glance – Short Tutorial
Introduction to JCL
In mainframe environments, COBOL is one of the primary programming languages used to develop business applications. To execute COBOL programs in batch mode, mainframes use a controlling language called JCL (Job Control Language).
JCL is used to tell the system what programs to execute, where to find those programs, what input data to provide, where to store the output, and how the different steps of a job should be processed.
Programs running in an online environment such as CICS generally do not require JCL for each individual transaction. However, JCL may still be used for related batch processing, such as compiling, linking, loading, or other utility jobs.
JCL does much more than simply execute programs. It can:
- Execute programs and system utilities.
- Provide input files to programs.
- Provide in-stream data.
- Pass parameters to programs using
PARM. - Allocate and create output files.
- Define where programs and files are located.
- Control the execution of job steps.
- Execute steps conditionally.
- Combine multiple programs into a single job.
- Facilitate batch processing and scheduling.
A single JCL job can therefore be used to execute several programs in a predefined sequence.
JCL has a specific syntax consisting primarily of positional parameters and keyword parameters.
JCL Coding Structure
JCL follows a specific column-based structure.
A valid JCL statement normally begins with // in columns 1 and 2.
For example:
//JOBTEST JOB MSGLEVEL=(1,1),MSGCLASS=X,NOTIFY=&SYSUID
The major components of a JCL statement are:
| Field | Description |
|---|---|
// | Identifies a JCL statement |
| Name field | Identifies the job, step, or DD statement |
| Operation field | Specifies the operation such as JOB, EXEC, or DD |
| Operand field | Contains parameters that control the operation |
| Comments | JCL comments begin with //* |
Column Structure
A simplified JCL layout looks like this:
----+----1----+----2----+----3----+----4----+----5----+----6
//NAME OPERATION OPERAND
1. Columns 1–2: JCL Identifier
A valid JCL statement normally begins with:
//
The // identifies the statement as a JCL statement.
For example:
//STEP01 EXEC PGM=TESTPGM
JCL also uses special forms such as:
//*
for comments.
The delimiter:
/*
is commonly used to indicate the end of in-stream data.
2. Name Field
The name field identifies a JCL element such as a:
- Job
- Step
- DD statement
For example:
//JOBTEST JOB ...
//STEP01 EXEC ...
//INPUT1 DD ...
The name field is generally limited to 1–8 characters.
The name field is optional for some JCL statements, so it does not have to be present in every statement.
3. Operation Field
The operation field specifies what type of JCL statement is being coded.
Common operations include:
JOBEXECDD
For example:
//JOBTEST JOB ...
//STEP01 EXEC PGM=TESTPGM
//INPUT1 DD DSN=MY.INPUT.FILE,DISP=SHR
The operation field is separated from the name field by at least one blank.
4. Operand Field
The operand field contains parameters that control the operation.
For example:
//STEP01 EXEC PGM=TESTPGM
Here:
PGM=TESTPGM
is an operand.
Multiple operands are generally separated by commas:
//JOBTEST JOB MSGLEVEL=(1,1),MSGCLASS=X,NOTIFY=&SYSUID
Operands can be continued on subsequent lines when required.
For example:
//CUSTOUT DD DSN=GBM.TEST.CUST.OUT.FILE,
// DISP=(NEW,CATLG,DELETE),
// SPACE=(CYL,(1,1),RLSE),
// DCB=(RECFM=FB,LRECL=133,BLKSIZE=0)
A Simple JCL Job
The following is a simple JCL job that executes a COBOL program called TESTPGM.
//JOBTEST JOB MSGLEVEL=(1,1),MSGCLASS=X,NOTIFY=&SYSUID
//STEP01 EXEC PGM=TESTPGM
//STEPLIB DD DSN=GBM.TEST.LOADLIB,DISP=SHR
//SYSPRINT DD SYSOUT=*
Let’s understand each statement.
JOB Statement
//JOBTEST JOB MSGLEVEL=(1,1),MSGCLASS=X,NOTIFY=&SYSUID
The JOB statement identifies the beginning of a job and specifies job-level parameters.
Here:
JOBTEST— Job name.MSGLEVEL=(1,1)— Controls the amount of JCL and allocation information written to the job output.MSGCLASS=X— Specifies the output class for job messages.NOTIFY=&SYSUID— Requests notification for the user who submitted the job.
EXEC Statement
//STEP01 EXEC PGM=TESTPGM
The EXEC statement identifies a job step and specifies the program to be executed.
Here:
PGM=TESTPGM
means that the program TESTPGM should be executed.
STEPLIB DD Statement
//STEPLIB DD DSN=GBM.TEST.LOADLIB,DISP=SHR
STEPLIB identifies the load library from which the system can load the program.
DISP=SHR indicates that the dataset is available for shared use.
SYSPRINT DD Statement
//SYSPRINT DD SYSOUT=*
This defines the destination for output associated with SYSPRINT.
SYSOUT=* generally directs the output to the same output class as the job’s system output.
Multiple Programs in a Single Job
A JCL job can contain multiple job steps. Each step can execute a different program or utility.
For example:
//JOBTEST2 JOB MSGLEVEL=(1,1),MSGCLASS=X,NOTIFY=&SYSUID
//* REPORT PROGRAM EXECUTION
//STEP01 EXEC PGM=TESTPGM
//STEPLIB DD DSN=GBM.TEST.LOADLIB,DISP=SHR
//SYSPRINT DD SYSOUT=*
//STEP02 EXEC PGM=REPRTPGM
//STEPLIB DD DSN=GBM.TEST.LOADLIB,DISP=SHR
//SYSPRINT DD SYSOUT=*
In this example:
STEP01executesTESTPGM.STEP02executesREPRTPGM.
The steps are normally processed sequentially, subject to any conditions or dependencies specified in the JCL.
This makes it possible to combine several related programs into a single batch job.
JCL Comments
Comments can be added to JCL using //*.
For example:
//* REPORT PROGRAM EXECUTION
//STEP02 EXEC PGM=REPRTPGM
The comment is ignored during execution and is useful for documenting the purpose of a job step.
Input and Output Files
A COBOL program frequently requires input files and produces output files.
JCL uses DD (Data Definition) statements to define the datasets that a program uses.
For example:
//SMPLJOB JOB MSGLEVEL=(1,1),MSGCLASS=D,NOTIFY=MG00T2
//* EXECUTES THE CUSTOMER REPORT PROGRAM
//CUST01 EXEC PGM=CUSARPT1
//STEPLIB DD DSN=GBM.TEST.LOADLIB,DISP=SHR
//CUSTIN DD DSN=GBM.TEST.CUST.IN.FILE,DISP=SHR
//CUSTOUT DD DSN=GBM.TEST.CUST.OUT.FILE,
// DISP=(NEW,CATLG,DELETE),
// SPACE=(CYL,(1,1),RLSE),
// DCB=(RECFM=FB,LRECL=133,BLKSIZE=0)
//SYSPRINT DD SYSOUT=*
In this example:
Input File
//CUSTIN DD DSN=GBM.TEST.CUST.IN.FILE,DISP=SHR
CUSTIN is the DD name that identifies the input dataset.
The COBOL program would normally reference this DD name through its SELECT and ASSIGN definitions.
Output File
//CUSTOUT DD DSN=GBM.TEST.CUST.OUT.FILE,
// DISP=(NEW,CATLG,DELETE),
// SPACE=(CYL,(1,1),RLSE),
// DCB=(RECFM=FB,LRECL=133,BLKSIZE=0)
This statement defines a new output dataset.
The important parameters include:
DSN— Dataset name.DISP— Dataset disposition.SPACE— Amount of disk space to allocate.DCB— Dataset characteristics such as record format and record length.
A program can have multiple input and output files, depending on its requirements.
Core JCL Features
The major JCL statements and concepts include:
- JOB statement
- EXEC statement
- DD statement
- Dataset allocation
- Dataset disposition
- In-stream data
- Parameters using
PARM - Conditional execution
- Job-step execution
- Output handling
- Procedures (
PROC) - Symbolic parameters
- Dataset concatenation
- Restart and checkpoint processing
Let’s look at the most important statements one by one.
JOB Statement
The JOB statement marks the beginning of a JCL job and provides information required by the operating system and the job-entry subsystem.
A typical JOB statement can look like this:
//JOBNAME JOB (ACCOUNT),'PROGRAMMER NAME',
// MSGLEVEL=(1,1),
// MSGCLASS=X,
// CLASS=A,
// TIME=10,
// REGION=0M,
// NOTIFY=&SYSUID
The exact parameters used depend on the installation and the job requirements.
Common JOB Parameters
JOBNAME
//JOBNAME JOB ...
JOBNAME is the name assigned to the job.
The job name is generally 1–8 characters long and must follow the naming rules of the system.
Example:
//PAYJOB01 JOB ...
Accounting Information
JOB (ACCOUNT)
The accounting information identifies the account or accounting information associated with the job.
For example:
//JOBNAME JOB (1234)
The exact format and requirement are installation-dependent.
Programmer Name
A programmer name can be specified on the JOB statement:
//JOBNAME JOB (1234),'JOHN'
This is primarily identification/documentation information and may be subject to installation-specific conventions.
MSGLEVEL
Example:
MSGLEVEL=(1,1)
MSGLEVEL controls which JCL statements and allocation-related messages are written to the job output.
The two values control different categories of messages.
MSGCLASS
Example:
MSGCLASS=X
MSGCLASS specifies the output class to which job messages are written.
The available classes are installation-dependent.
CLASS
Example:
CLASS=A
CLASS specifies the execution class assigned to the job.
The meaning of individual classes depends on the installation’s JES configuration.
TIME
Example:
TIME=10
TIME can be used to specify a processor time limit for the job or job step, depending on where it is coded.
The exact behavior and acceptable values depend on the system configuration.
REGION
Example:
REGION=0M
REGION specifies the amount of virtual storage available to a job step.
For example:
REGION=0M
is commonly used at installations where the system policy allows the job to use the available region size.
The use and interpretation of REGION can vary with the z/OS environment and installation standards.
NOTIFY
Example:
NOTIFY=&SYSUID
NOTIFY specifies the user ID that should be notified when the job completes.
&SYSUID is a system symbolic variable that represents the submitting user ID.
For example:
//JOBNAME JOB NOTIFY=&SYSUID
is commonly used so that the submitting user receives notification.
EXEC Statement
The EXEC statement defines a job step and specifies the program or procedure to be executed.
For example:
//STEP01 EXEC PGM=TESTPGM
Here:
STEP01is the step name.EXECis the operation.PGM=TESTPGMspecifies the program to execute.
A job can contain multiple EXEC statements:
//STEP01 EXEC PGM=PROGRAM1
//STEP02 EXEC PGM=PROGRAM2
//STEP03 EXEC PGM=PROGRAM3
Each EXEC statement represents a separate job step.
DD Statement
The DD statement defines the data required by a job step.
DD stands for Data Definition.
For example:
//INPUT1 DD DSN=MY.INPUT.FILE,DISP=SHR
The DD name is:
INPUT1
The dataset being referenced is:
MY.INPUT.FILE
and:
DISP=SHR
indicates that the existing dataset is being referenced with shared disposition.
A DD statement can define:
- Input datasets
- Output datasets
- Temporary datasets
- SYSOUT
- In-stream data
- System resources required by a program
Summary
JCL is the language used to define and control batch jobs in z/OS environments.
The three most important JCL statements for beginners are:
JOB → Defines the job
EXEC → Defines what to execute
DD → Defines the data/resources used by the step
A simple way to remember them is:
JOB → Who/what is the job?
EXEC → What should be executed?
DD → What data does it need?
A typical JCL job therefore looks like:
//JOBNAME JOB ...
//STEP01 EXEC PGM=PROGRAM1
//INPUT1 DD DSN=INPUT.DATASET,DISP=SHR
//OUTPUT1 DD DSN=OUTPUT.DATASET,
// DISP=(NEW,CATLG,DELETE),
// SPACE=(CYL,(1,1),RLSE)
//SYSPRINT DD SYSOUT=*
Understanding the JOB, EXEC, and DD statements provides the foundation for learning more advanced JCL concepts such as conditional execution, GDGs, temporary datasets, procedures, symbolic parameters, in-stream data, dataset concatenation, restart processing, and JCL utilities.
