|
|||||
|
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
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.
//SIMOJOB1 JOB (ACCTINFO),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.
The (ACCTINFO) is accounting information an 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 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. |
The MSGLEVEL=(x,y) is used as follows.
| x | 0 | The system prints only the JOB statement. |
| 1 | The system prints all JCL statements, JES2, or JES3 control statements, the procedure statements, and IEF653I messages which show the values assigned to symbolic parameters in procedure statements. | |
| 2 | The system prints only JCL statements and JES2 and JES3 control statements. | |
| 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 is defined by a "//*" in positions 1-3. The following is an example of a JCL comment statement.
//* THIS IS A JCL COMMENT STATEMENT...
Note: The text for the comment should not go past position 71. Remember, a non-space in position 72 indicates a continuation.
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.
//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.
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.
//* A Sample format for a DD statement ... //ddname DD DSN=data.set.name,DISP=parameter
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 Value | Description |
| DISP=OLD | The dataset exists and this job step has exclusive use of the dataset. |
| DISP=SHR | The dataset exists and other users and jobs can access the dataset |
| DISP=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. |
| DISP=NEW | The dataset does not exist and will be created. |
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.
//* A sample JCL DD statement for an existing data set... //QSAM0080 DD DSN=SIMOTIME.DATA.QSAM0080,DISP=SHR
The following is an example of a COBOL SELECT statement with an ASSIGN clause.
* A COBOL Select Statement...
SELECT QSAM0080-FILE ASSIGN to QSAM0080
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)
The following describes the DISP options.
| 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. |
The following describes the DCB options.
| 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
The following is an example of a COBOL SELECT statement.
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=*
The following is a sample COBOL statement that uses DISPLAY
DISPLAY 'This is a test...'
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
The following is the COBOL SELECT statement.
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).
open input QSAM0080-FILE
...
read QSAM0080-FILE.
...
close QSAM0080-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.
The two techniques use to pass information (a Parameter) from JCL to a program are as follows.
| Technique | Description |
| via PARM= | This technique uses a PARM=parameter keyword on the EXEC statement in JCL. 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'
To pass a parameter from SYSIN to a program requires the use of DD statement for SYSIN. The following JCL statement is required if no parameter is passed.
//* ******************************************************************* //* 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... //*
The following shows the COBOL statement required.
ACCEPT variable-name 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.
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.
//PDSCRTJ4 JOB SIMOTIME,ACCOUNT,CLASS=1,MSGCLASS=0,NOTIFY=CSIP1 //* ******************************************************************* //* This program is provided by: * //* SimoTime Enterprises, LLC * //* (C) Copyright 1987-2003 All Rights Reserved * //* * //* Web Site URL: http://www.simotime.com * //* e-mail: helpdesk@simotime.com * //* ******************************************************************* //* //* Subject: Define a PDS using the IEFBR14 with a DD Statement //* Author: SimoTime Enterprises //* Date: January 1,1998 //* //* The JCL member executes the instream PROC called PDSCRTP3 and //* passes a fully qualified data set name (DSN) via the symbolic name //* called DSNAME and referenced in the PROC as &DSNAME. //* //********************************************************************* //* The instream PROC for creating a PDS. The Data Set Name (&DSNAME) //* is provided by the job step that calls the PROC. //* //PDSCRTP3 PROC //PDSCRTS1 EXEC PGM=IEFBR14 //TEMPLIB1 DD DISP=(NEW,CATLG),DSN=&DSNAME, // STORCLAS=MFI, // SPACE=(TRK,(45,15,50)), // DCB=(RECFM=FB,LRECL=80,BLKSIZE=800,DSORG=PO) // PEND //* //* ******************************************************************* //* Step 1 of 3 Create a PDS using SET and EXEC //* // SET DSNAME=SIMOTIME.DEMO.TEMP01 //STEPJ41 EXEC PDSCRTP3 //* //* ******************************************************************* //* Step 2 of 3 Create a PDS using EXEC and DSNAME substitution //* //STEPJ42 EXEC PDSCRTP3,DSNAME=SIMOTIME.DEMO.TEMP02 //* //* ******************************************************************* //* Step 3 of 3 Create a PDS using EXEC and DSNAME substitution //* //STEPJ43 EXEC PDSCRTP3,DSNAME=SIMOTIME.DEMO.TEMP03 //*
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.
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.
//SIMOJOB1 JOB (ACCTINFO),CLASS=A,MSGCLASS=C,NOTIFY=USERID //JOBLIB DD DSN=SIMOTIME.DEVL.LOADLIB1,DISP=SHR //* //STEP0100 EXEC PGM=PROGRAM1 //* //STEP0200 EXEC PGM=PROGRAM2 //* //STEP0300 EXEC PGM=PROGRAM3 //STEPLIB DD DSN=SIMOTIME.DEVL.TEMPLIB1,DISP=SHR //* //STEP0400 EXEC PGM=PROGRAM4
In the preceding example PROGRAM1 of STEP0100, PROGRAM2 of STEP0200 and PROGRAM4 of STEP0400 will run from the library SIMOTIME.DEVL.LOADLIB1 that is specified in the JOBLIB statement. PROGRAM3 of STEP0300 will run from the library SIMOTIME.DEVL.TEMPLIB1 that is specified in the STEPLIB statement that overrides the JOBLIB statement.
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.
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: helpdesk@simotime.com
You may download this example at http://www.simotime.com/sim4dzip.htm#JclQuickReferenceZip as a Z-Pack. The Z-Packs provide individual programming examples, documentation and test data files in a single package. The Z-Packs are usually in zip format to reduce the amount of time to download.
Please view the complete list of SimoTime Z-Pack Examples at http://www.simotime.com/sim4dzip.htm.
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 .
If you have any questions, suggestions or comments please call or send an e-mail to: helpdesk@simotime.com.
Founded in 1987, SimoTime Enterprises is a privately owned, Limited Liability Corporation located in Novato, California. We specialize in the creation and deployment of business applications using new or existing technologies and services. We have a team of individuals that understand the broad range of technologies being used in today's environments. This includes the smallest thin client using the Internet and the very large mainframe systems. There is more to making the Internet work for your company's business than just having a nice looking WEB site. It is about combining the latest technologies and existing technologies with practical business experience. It's about the business of doing business and looking good in the process. Quite often, to reach larger markets or provide a higher level of service to existing customers it requires the newer Internet technologies to work in a complementary manner with existing corporate mainframe systems. Whether you want to use the Internet to expand into new market segments or as a delivery vehicle for existing business functions simply give us a call or check the web site at http://www.simotime.com.
| Return-to-Top |
| Copyright © 1987-2008 SimoTime Enterprises, LLC All Rights Reserved |
| When technology complements business |
| http://www.simotime.com |
| Version 03.04.11 |