Introduction

Job Control Language (or JCL) specifies how programs are run on the mainframe. JCL functions as the interface between the programs and the operating system. Since JCL has the ability to define data set names, parameters and system output individual programs can be flexible in their use because these items are not hard coded. 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

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.

The Job Statement (or Job Card)

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, & 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
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.

The EXEC Statement (or Defining a Job Step)
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 Data Sets

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 Statement for an Existing Data Set

    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 DD Statement for a New Data Set
    (Next) (Previous) (Table-of-Contents)
    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.

    Data Set Concatenation
    (
    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.

    Directing System Output
    (Next) (Previous) (Table-of-Contents)
    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 DUMMY Data Set
    (Next) (Previous) (Table-of-Contents)
    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.

    Passing a Parameter to a Program

    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.

    Passing a Parameter via PARM=
    (Next) (Previous) (Table-of-Contents)
    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'

    Passing a Parameter via SYSIN
    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 Procedures or PROC's

    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.

    //*********************************************************************
    //* 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.

    Specifying the Location 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.

    //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.

    Next Page :- 1 2 3 4 5