JCL Shortnotes
Why do we need JCL?
To complete a task (assume it is program execution) in the mainframe environment, a set of instructions should provide to the mainframe. These sets of instructions are coded using the JCL control statements.
What is JCL?
JCL (Job Control Language) is a programming language with a set of predefined instructions that are used by the JOB ENTRY SUBSYSTEM (JES2 or JES3) to instruct the system on how to run a batch job or start a subsystem.
Where JCL used?
The batch process allows processing in the background and notifies the status once the task is completed. Batch process requests are submitted (manually by the user or automatically by the schedular) using JOB (coded with JCL control statements).
What is a JOB?
We need to code some JCL statements together to perform a task. All the statements coded together for a task are called as JOB.
What JOB can do?
- Pass values to an application program using PARM parameter in EXEC statement.
- Compile a program.
- Run a program (COBOL / COBOL + DB2).
- Bind DB2 program.
- Create datasets. i.e., PS and PDS.
- Create GDG and VSAM files.
- Copy data from one file to other.
- And so on..
The JCL coding sheet is a structure to identify from where each statement coding should start and how each one is different from other statements.
Columns | Description |
---|---|
1& 2 Columns | Every line in the JOB should start with null indicator(//) except the input stream (SYSIN). |
3 | '*' in the third column specifies that the line is a comment. |
3-10 | 1-8 character Name Field (job-name/step-name/dd-name). |
11 | One space to separate the Name and Operation fields. |
12-15 | Operation (JOB/EXEC/DD). |
16 | One space to separate the Operation and Operands fields. |
17-71 | Reserved for Operands (parameters for the operation). |
72 | Reserved for Continuation column (,). |
JCL Statement -
JCL statement is an active statement (without '*' in the third column) that considers as an instruction to OS. JCL statements are three types -
- JOB Statement.
- EXEC Statement.
- DD Statement.
JCL Comment -
JCL comment is an inactive statement that provides information about the task or other JCL statements. Comment should have a '*' in the 3rd column.
JCL structure defines the predefined structure to create a JOB. First of all, let us see the structure of JCL with all three types of statements -
Every JCL is divided into two parts based on the statements coding -
- JOB Card
- JOB Body
JOB Card -
A JOB card makes the OS aware of the specific job after it submits and provides the parameters required to run the job. It is mandatory for the job to run and should code only once at the beginning of the job.
JOB Body -
Except the JOB card, the remaining part of the JCL is called as JOB Body. A JOB Body contains multiple steps and can have up to 255 steps (EXEC statements).
The Operating System uses Job Entry System (JES/JES2/JES3) to receive the submitted jobs, run/schedule them for processing, and manage the output.
- Submit JOB - Submitting the JOB for processing.
- JOB Entry System - Accepts the job for processing.
- JOB Execution Ready - JES will replace all symbolic parameters, PROCS, convert the total JOB into a single JOB, and makes execution ready with all parameters.
- JOB Queuing - JES decides the priority of the JOB execution based on CLASS and PRTY parameters in the JOB statement.
- Job Execution - When the JOB reaches its highest priority, JOB gets active for execution from the JOB queue.
- JOB syntax and File Validation - The JCL errors and file validations are handled in this step. If there are no errors, the JOB gets completed successfully. If there are errors, JOB failed with JCL errors.
- Purging - When the JOB is completed (Successfully/Unsuccessfully), the allocated resources and spaces are released.
A JOB statement with all its parameters is also called as JOB Card. JOB card can be coded in multiple lines with a continuation character (,) immediately after the parameter anywhere from 17 to 72 columns.
Syntax -
//job-name JOB job-card-parameters
The JOB statement is divided into three parts -
- JOB Name (job-name).
- JOB Operation (JOB).
- JOB Card parameters (job-card-parameters).
JOB Name (job-name) -
- JOB name is the first word in the JOB statement and is used to identify the job.
- It starts from the 3rd column and ends at the 10th column.
- name length can be a minimum of 1 character and a maximum of 8 characters.
JOB Operation (JOB) -
- JOB is the keyword used to code the JOB statement in JCL.
- A job has only one JOB statement.
JOB Card parameters (job-card-parameters) -
- JOB Card parameters are treated as global and applies to each step in the job.
- If any parameter is coded at the step and JOB level, the step level parameter has the highest priority.
- JOB Card parameters are divided into two types -
- Positional parameters.
- Keyword parameters.
JOB card parameters that are very specific about their position are called as positional parameters. There are two positional parameters in the JOB card -
- Accounting information.
- Programmer name.
Accounting information -
Accounting information is the billing name to which the CPU processing time for the entire job is billed. It is mandatory and should enclose with ().
Example - JOB (@POSPARM) with ACCT123 as accounting information.
//@POSPARM JOB (ACCT123),'PAWAN Y',NOTIFY=&SYSUID
Programmer name -
The programmer name is used to identify who is responsible for the specific job. It is optional and can be a user-defined name enclose with single quote(').
Example - JOB (@POSPARM) with 'PAWAN Y' as programmer name.
//@POSPARM JOB (ACCT123),'PAWAN Y',NOTIFY=&SYSUID
All other parameters except positional parameters in the JOB statement are called keyword parameters. Information passed in keyword parameters used by the JES (Job Entry System).
Frequently used Parameters -
CLASS | It is used to classify the jobs. The classification is based on how much time they are running. i.e., SHORT RUN or LONG RUN jobs. |
MSGCLASS | It is used to specify the output device to where the system and JCL messages are routed (written and printed). |
MSGLEVEL | It controls the printing of job messages in the output listing or job log (i.e., in the SPOOL by default). |
PRIORITY | It is used to assign a selection priority to jobs. JES system uses the PRTY value to decide the execution sequence of the jobs when they have same CLASS value. |
TIME | It is used to specify the maximum CPU utilization time allowed for the job to execute. The system will automatically cancel the job execution if the execution time exceeds the specified time. |
REGION | It is used to specify the amount of central or virtual memory required to execute the job. The system applies it to each step of the job. |
NOTIFY | It is used to notify the user about the job status (either successful or unsuccessful). |
RESTART | It is used to restart the job execution from a specific step (at which step the job failed). The step can be a job step, a procedure step, or a checkpoint. |
COND | It controls the printing of job messages in the output listing or job log (i.e., in the SPOOL by default). |
Rarely used Parameters -
ADDRSPC | ADDRSPC parameter is used to specify the type of storage (virtual or central) needed by the system to process the job. |
SCHENV | SCHENV parameter specifies the WLM (Work Load Manager) scheduling environment that is associated with the current job when submitted. |
TYPERUN | TYPRUN is used to request special job processing like scanning jobs for syntax errors, library errors, etc. |
BYTES | BYTES parameter is used to specify the maximum amount of output to be printed on SYSOUT datasets in terms of bytes. |
JESLOG | The JESLOG parameter is used to specify whether the JESLOG (JESMSGLG and JESYSMSG) files are spin-eligible or not. |
JOBRC | JOBRC means the JOB Return Code. The JOBRC parameter is used to control how the job return code is set. |
LINES | LINES parameter is used to specify the maximum output lines to be printed on SYSOUT datasets. |
PAGES | The PAGES parameter is used to specify the maximum output pages to be printed on SYSOUT datasets. |
RD | RD stands for restart definition. RD parameter used to -
|
SECLABEL | SECLABLE represents the security level and security categories defined by RACF. |
MEMLIMIT | The MEMLIMIT parameter is used to specify the virtual memory limit (above the default limit) that a job can use from the total virtual memory space. |
SYSTEM | SYSTEM is used to specify the eligible systems to process the job. |
USER | The USER parameter is used to identify who submits (userid) the job. |
PASSWORD | The PASSWORD parameter is used to identify the current RACF password. |
GROUP | The GROUP parameter is used to specify the userID connecting the RACF-defined group. |
SYSAFF | SYSAFF is used to specify the JES2 members and JES3 systems that are eligible to process the job. |
UJOBCORR | UJOBCORR is used to specify the user portion of the job correlator. |
DSENQSHR | DSENQSHR parameter specifies how the system treats the file disposition changes between the job steps. |
EXEC statement treats as the beginning of the step and required for each step. A JCL can have a maximum of 255 steps. Syntax -
//[stepname] EXEC parameters [comments]
Stepname - Step name is used to identify the step uniquely in the JCL. Step name is optional and can be 1-8 characters.
EXEC keyword - It is the keyword used to code the step in JCL. A job can have 255 steps.
Parameters -
EXEC statement parameters are divided into three types -
- Positional parameters.
- Keyword parameters.
- Symbolic parameters.
Positional Parameters -
Parameter | Purpose |
---|---|
PGM | It is used to specify the program that needs to be run by the system. |
PROC | It is used to specify the procedure that needs to be run by the system. |
Keyword Parameters - Below parameters that are part of JOB statement and also applicable to EXEC statement -
Parameter | Purpose |
---|---|
ACCT | Specifies step accounting information. |
ADDRSPC | Specifies the type of the storage required for the step. |
COND | Specifies the return code tests used to determine the specific step execution. |
MEMLIMIT | Specifies the limit on total number of usable virtual pages above the bar. |
RD | Specifies the user authority for automatic restart. |
REGION | Specifies the Maximum amount of space required by the step. |
TIME | Specifies the Maximum amount of processor time the step can use. |
Below keyword parameters that are not part of JOB statement and only applicable to EXEC statement -
Parameter | Purpose |
---|---|
DYNAMNBR | Holds the number of dataset allocations for reuse. |
PARM | Used to pass the input data to the program. |
DD (Data Definition) statement is used to specify input and output files for a job step. It defines a dataset or file name, attributes, and location and assigns it a DDname to be referenced within the job step. Syntax -
//DDname DD parameters [comments]
DDname - It is the name assigned to the dataset or file being defined. DDname is optional and can be 1-8 characters.
DD - It is the keyword used to code the DD statement in JCL and a step can have a maximum of 3273 files.
Parameters -
Frequently used Parameters -
Keyword Parameter | Purpose |
---|---|
DSNAME | Used to specify the name of a dataset. |
DISP | specifies how a dataset is to be handled in the job or job step. |
SYSOUT | Sends the sysout dataset to specified destination |
SPACE | used to specify the amount of disk space required for creating a new dataset and the allocation should request on direct access volume (DSAD). |
UNIT | used to specify the system to place the dataset on a specific device or a group of devices. |
DSORG | specifies the organization of the dataset. The value of this parameter determines how the data in the dataset is arranged and accessed. |
RECFM | used to define the record format for the new dataset. |
LRECL | used to specify the record length for new datasets during their creation. |
BLKSIZE | used to specify the size of the physical blocks used when reading or writing a dataset. |
DCB | used to define how a dataset is to be processed. It provides information about the organization, record format, record length, block size, and other dataset attributes. |
VOLUME | used to specify the name of the DASD (Direct Access Storage Device) volume on which a dataset is stored or is to be stored. |
LIKE | It allows you to create a new dataset with the attributes of an existing dataset. |
Rarely used Parameters -
Keyword Parameter | Purpose |
---|---|
RECORG | Specifies the record organization |
DSNTYPE | Specifies the type of the dataset |
DEST | Sends the sysout dataset to specified destination |
EXPDT | Specifies the expiration date for the dataset |
KEYLEN | Specifies the length of the key in the dataset |
OUTLIM | Specifies the logical records limit in the dataset |
RETPD | Specifies the retention period of the dataset |
DYNAM | DYNAM parameter to provide the compatibility with previous system. |
OUTPUT | Associates with one or more output datasets |
LABEL | Specifies the information about the dataset label |
JCL library normally refers to a dataset or collection of datasets that contain reusable JCL code or procedures. There are several types of libraries in JCL -
- System libraries
- User-defined libraries
System libraries -
A system library contains standard or system-defined JCL procedures and utilities provided by the mainframe operating system. z/OS has many standard system libraries and few important libraries include -
- SYS1.LINKLIB - contains many of the basic execution modules of the system.
- SYS1.PROCLIB - contains JCL procedures distributed with z/OS.
- SYS1.PARMLIB - contains control parameters for z/OS and for some program products.
- SYS1.LPALIB - contains system execution modules loaded into the link pack area when the system is initialized. Programs stored here are available to other address spaces.
- SYS1.NUCLEUS - contains the basic kernel modules of z/OS.
- SYS1.SVCLIB - contains operating system routines known as SVCs.
User-defined libraries -
Library | Purpose |
---|---|
STEPLIB | specifies user-defined load library at the step level. |
JOBLIB | specifies user-defined load library at the job level. |
JCLLIB | specifies the private libraries that contain the cataloged procedures. |
PROCLIB | specifies a user-defined library where commonly used procedures are stored. |
COPYLIB | specifies the copybook library in the compilation step of the JCL. |
The input and output statements are used to define the data sets or files that a batch job (a job that executes a COBOL program) will use during its execution.
These statements are required when the program is accepting input or writing output. JCL input and output statements are -
SYSIN Statement -
It is used to provide the input source for programs or utilities in the JCL.
Example - SYSIN statement with a dataset.
//SYSIN DD DSN=input.data.set,DISP=SHR
SYSOUT Statement -
It is used to specify where to route the output produced by a job step.
Example - Writing to a dataset (MATEPK.SYSOUT.PS).
//TESTJOB JOB ...
//STEP1 EXEC PGM=PROG1
//SYSOUT DD DSN=MATEPK.SYSOUT.PS,
// UNIT=3390,
// VOLUME=SER=123456,SPACE=(CYL,(0,1)),
// DISP=(NEW,CATLG,DELETE)
//SYSIN DD *
...
/*
Conditional statements are used to control the execution flow within a job based on certain conditions. They allow us to specify when a particular job step should be executed or skipped.
There are three primary types of conditional statements in JCL -
The "IF" statement is used to execute a step conditionally based on the condition coded. If the condition is true, then the step that follows the IF statement gets executed, and if the condition is false, the step execution gets skipped.
Example - Executing STEP02 when STEP01 abended or RC > 8.
//Jobcard
//STEP01 DD PGM=PROG1
//IFSTEP2 IF ( ABEND | STEP01.RC > 8 ) THEN
//STEP02 EXEC PGM=PROG2
//IFSTEP2E ENDIF
//STEP03 EXEC PGM=PROG3
It is used to specify a condition under which a particular job step should be executed or skipped. It allows us to control the flow of execution within a job based on the result code (return code) of a previous job step or based on other conditions.
Example - Executing STEP3 based on the return code of STEP1.
//MTHEXMP1 JOB (META007),'PAWAN Y',NOTIFY=&SYSUID
//STEP1 EXEC PGM=P1
//STEP2 EXEC PGM=P2
//STEP3 EXEC PGM=P3,COND=(12,EQ,STEP1)
//STEP4 EXEC PGM=P4
In this example, STEP3 will be executed when STEP1 return code is not equal to 12.
RD stands for restart definition. RD parameter used to - allow JES to perform an automatic job restart after the job failure, allow the operator to perform an automatic job or a checkpoint restart if a job fails.
Example - Automatic restart for job level and No restart at step level.
//MTHEXMP1 JOB (META007),'PAWAN Y',RD=R
//*
//STEP01 EXEC ...
//STEP02 EXEC ...
//STEP03 EXEC ...
//STEP04 EXEC PGM=PROG04,RD.STEP02=NR
//STEP05 EXEC PGM=PROG05
RD=R specifies that the operator can perform automatic restart if the job fails. The RD parameter at the STEP04 is ignored.
Temporary datasets are created and used during the execution of a job. These datasets are temporary and deleted at the end of the job (not at the end of the step). The naming convention for temporary datasets typically begins with an ampersand (&&) followed by a unique name.
Example - Defining an temporary PS file with LRECL of 500 bytes
//NEWPS DD DSN=&&TEMPPS,
// DISP=(NEW,PASS,),
// UNIT=SYSDA,
// SPACE=(TRK,(3,2),RLSE),
// DCB=(DSORD=PS,RECFM=FB,LRECL=500,BLKSIZE=5000)
Concatenating datasets is a process of combining two or more same types of datasets into a single logical dataset that can be accessed as a single unit. To concatenate datasets in JCL, we can use the DD statement and multiple datasets with the one DDname.
Example - Concatenating multiple datasets.
//STEP01 EXEC PGM=PROG1
//INPUT DD DSN=MATEPK.INPUT.PS,DISP=SHR
// DD DSN=MATEPK.INPUT.PS1,DISP=SHR
The two PS files are accessed as a single file under INPUT DDname in PROG1.
A procedure is a reusable set of JCL statements defined once and called multiple times within a job or across various jobs. Procedures are of two types based on their definition and usage -
- Instream procedure.
- Cataloged procedure.
An instream procedure is a type of procedure that is defined within the same JCL where it calls. A maximum of 15 instream procedures can be coded in any job.
The procedure defined outside of the JCL is called as cataloged procedure. A maximum of 255 procedures can be coded in a single JCL.
Nested procedures (PROC) are a technique to create a PROC that contains a call to another PROC. Procedures can be nested up to 15 levels.
Symbolic parameters allow us to pass information from JCL to procedures (PROCs), making PROCs reusable with different values when calling from different JCLs. Symbolic parameters are placeholders or variables used in PROCs. They receive variable data from JCL, which replaces symbolic variables in PROC.
Defining Symbolic Parameters -
Case 1. Definition using SET statement -
// SET SYMVAR=value
Case 2. While calling PROC -
//step-name EXEC proc-name,SYMVAR=value
Referencing Symbolic Parameters in PROCs -
//..........&SYMVAR
Overriding parameters is a technique that allows us to replace the coded parameter values temporarily. The overriding parameters can be coded with the EXEC statement at the step level.
Overriding parameter can be done in 3 ways -
- Replacing existing parameter - This overriding type replaces the existing parameter, which is already coded in PROC.
- Adding new parameter - This type of overriding adds the parameter to the statement that is not already coded in PROC.
- Nullify existing parameters - This type of overriding deletes the existing parameter that is already coded in PROC.
The referback (backward reference) is used to get the information from the previous steps to the current step. "*" is used as a referback operator.
Example - Using the DCB of INPUT ddname in the same step.
//STEP02 EXEC PGM=PROG
//INPUT DD DSN=MTH.INPUT.FILE2,DISP=SHR
//OUTPUT DD DSN=MTH.OUTPUT.FILE,
// DISP=(NEW,CATLG,DELETE),
// SPACE=(CYL,(10,10),RLSE),
// DCB=*.INPUT
An error dump describes the system state that can be written to a file when a program or job abnormally terminates due to an error or failure. The error dump can be used for debugging and troubleshooting. Those JCL statements are -
- SYSABEND - It used to specify the system dump dataset in the JCL.
- SYSMDUMP - It dumps the system areas and the program's address space. The dumps are unformatted, machine-readable, and are only ABEND dumps.
- SYSUDUMP - It produces a dump of user areas. The dump is formatted and readable.