JOB Control Language (JCL)
This document explains how to use Job Control Language (JCL) on the MVS mainframe system.
Job Control Language is used to request the resources that a job needs to run on the system. Throughout this document, lowercase words in the JCL statement syntax denote user-supplied information; uppercase information is typed as it appears. Note: All JCL statements must be in uppercase letters; otherwise a JCL error will occur. For more information, refer to the IBM OS/VS2 MVS JCL Manual.
JCL statements have the following general syntax:
//name operation operand comments
- name
- identifies the JCL statement and is optional on the EXEC statement and concatenated DD statements.
- operation
- specifies the type of JCL statement and must be preceded and followed by one or more blanks.
- operand
- is a list of positional and/or keyword parameters separated by commas. Positional parameters must be coded in a particular order; keyword parameters may be coded in any order. This field must be preceded and followed by one or more blanks; blanks are not allowed between parameters. The operand field must begin before column 16 and may not extend past column 71; however, the field may be continued onto another statement by stopping after a comma and coding // in columns 1 and 2 of the next statement followed by at least one blank and the rest of the parameters.
- comments
- are optional if operands are coded; comments must start past column 17 if operand(s) are not coded.
Comment Statement
The COMMENT statement allows the user to insert comment statements between the JCL statements to clarify the function of the JCL statements.
The general form of the COMMENT statement is:
//* comment
Example:
//*
//* THIS JOB PRODUCES MAILING LABELS
//*
EXEC Statement
An EXEC statement is used to invoke the JCL in a catalogued procedure or to invoke a specific program (load module). Catalogued procedures contain JCL that has potential use by many users; catalogued procedures reside in SYS1.PROC2LIB. An EXEC statement is the first statement in a job step; a job may have multiple steps and hence multiple EXEC statements.
The format for an EXEC statement is:
//stepname EXEC
type,COND=(number,condition,step,...),
// PARM='value',REGION=nK,TIME=(m,s)
- stepname
- specifies the name of the step. It is entirely optional; however, in a multiple-step job, it is wise to specify a unique stepname for each step. The name must be 1 to 8 characters starting with a letter.
- EXEC
- identifies the statement as an EXEC statement.
- type
- specifies either the name of a catalogued procedure or PGM=pgmname, where pgmname is a program name.
- COND
- specifies condition(s) for executing subsequent job steps. Each number is compared against the return code from a prior step, and if any comparison is true, the step is bypassed. A maximum of eight comparisons is allowed.
- number
- is a number that is compared against the return code from a prior step.
- condition
- can be EQ (equal), NE (not equal), GE (greater than or equal), LE (less than or equal), GT (greater than), or LT (less than).
- step
- is the name of a specific stepname from which the return code is tested; if step is omitted, the return code from each previous step is used in the test.
- Condition codes can range from 0 to 4095. Common condition codes are:
- 0
- no errors or warnings detected
- 4
- possible error (warning) detected but execution is possible.
- 8
- serious error detected, likely to fail.
- 12
- severe error detected, execution impossible.
- 16
- terminal error, execution cannot continue.
- PARM
- specifies control information to be passed to a job step, where 'value' may contain more than one expression separated by commas.
- REGION
- specifies the memory for a particular job step; n is a multiple of 64. This region must not be greater than the total job region.
- TIME
- specifies the maximum CPU time that the job step will use;m is minutes and s is seconds. The time must not be greater than or equal to the total job time.
Examples:
This statement executes a program called IEBGENER
// EXEC PGM=IEBGENER
This executes a catalogued procedure for SAS.
// EXEC SAS
The following job contains two steps. The first step executes the FORTVCL catalogued procedure which compiles a FORTRAN program and links it (resolves external references), thus creating a load module. The second step executes the catalogued procedure FORTVG, which runs the compiled and linked program stored in USER.ONE under the name of TEST.
Using keyword parameters in STEP1, you can specify that the load module TEST is to be stored in a load library called USER.ONE. The load library is a partitioned dataset.
In STEP2, the load module TEST in the load library USER.ONE is to be executed. The condition code parameter causes this step to be skipped if the condition code of any previous step was greater than 8.
//STEP1 EXEC FORTVCL,PDS='USER.ONE',NAME=TEST
//STEP2 EXEC FORTVG,PDS='USER.ONE',NAME=TEST,
// COND=(8,LE)
The following statement compiles and links a FORTRAN program called TWO and stores it in a load library called USER.TWO.LOAD. The .L immediately after the COND means that the parameter (4,LT,C) is to be passed to the link step of the catalogued procedure FORTVCL.
// EXEC FORTVCL,PDS='USER.TWO.LOAD',NAME=TWO,
// COND.L='(4,LT,C)'
The following statement executes a program called ROUND, and requests a space of 128M for STEP1 of the job.
//STEP1 EXEC PGM=ROUND,REGION=128M
The following statement executes the ALGOLW compiler and limits the job step to 5 minutes and 30 seconds of CPU time.
//STEP1 EXEC ALGOLW,TIME=(5,30)
The TIME parameter can be used on a multiple step job where it is important that there be enough time remaining for some following step to execute, even at the cost of prematurely terminating a previous step.
Data Definition (DD) Statement
The DD statement describes a dataset, requests allocation of input and output resources, and provides information for the retrieval and storage of data.
The format of a DD statement can be one of the following:
//ddname DD *
//ddname DD DATA,DLM=xx
//ddname DD DUMMY
//ddname DD SYSOUT=(class,,forms)
//ddname DD DSN=dataset.name,
// DCB=(BLKSIZE=b,DEN=d,LRECL=n,RECFM=r,TRTCH=t),
// DISP=(current-status,normal-disposition,abnormal-disposition),
// LABEL=(file,label-type,,processing-type),
// SPACE=(type,(primary,secondary,directory-blocks),RLSE),
// UNIT=device,
// VOL=SER=name
- ddname
identifies the DD statement. Its value is determined by the program being executed.
DD
identifies the statement as a data definition statement.
*
specifies that data follows immediately; no keyword parameters may follow. The data may not contain any records beginning with // or /*.
DATA
specifies that data follows immediately; keyword parameters may follow the DATA positional parameter. The data may contain records beginning with //, but none beginning with /*.
DLM
changes the JCL delimiter /* to a specified value until those characters are encountered in columns 1 and 2; the delimiter is then reset to /*.
xx
may be any two letters, numbers, or national characters (@ # $). You must put these 2 characters as the last line of your input for this file.
DUMMY
specifies that if the file is an output file, the output is to be discarded. If the file is an input file, it specifies that there is no data.
SYSOUT
specifies the disposition of an output dataset. Examples of SYSOUT:
SYSOUT=A specifies regular computer paper.
SYSOUT=(A,,0001) specifies white unlined paper
- DSN
- dataset.name
specifies the name of a dataset that is to be used.
- DCB
- describes the dataset.
- BLKSIZE
- specifies the number of bytes (characters) per block, where b is a multiple of the LRECL.
- DEN
- specifies the tape density (1600 bpi or 6250 bpi), where d is 3 for 1600 bpi and 4 for 6250 bpi. If DEN=d is omitted, the default for writing on the first file of a tape is DEN=4 (6250 bpi).
- LRECL
- specifies the logical record length (n) for fixed or variable length records; omit LRECL for records of undefined length.
- RECFM
- specifies the record format. Common values for r are U for undefined-length records, V or VB for variable-length or variable-blocked records, F or FB for fixed-length or fixed-blocked records, and FA, FBA, or VBA for fixed, fixed-blocked, or variable-blocked records with a printer control character as the first byte of data.
- TRTCH
- by default, cartridge tapes are written in compressed format. If you need to create a non-compressed cartridge tape you must specify TRTCH=NOCOMP. This is applicable only to cartridge tapes and not reel tapes.
- DISP
- specifies the current status of a data set and indicates the disposition of the dataset at the end of a job step.
- current-status
- may be NEW for a dataset that is to be created, OLD for a dataset that exists and is to be exclusively used by the job, SHR for a dataset that exists and may be shared by more than one job, and MOD for a new dataset or one that exists and is to be modified by adding onto the end of the dataset.
- normal-disposition
- specifies the disposition of the dataset after successful completion of the job. DELETE deletes the dataset, KEEP retains the dataset, PASS passes the data set to the next job step, CATLG catalogs the data set, and UNCATLG uncatalogs the dataset. If current-status is NEW, normal-disposition defaults to DELETE. If current-status is MOD, OLD, or SHR, normal-disposition is KEEP.
- abnormal-disposition
- specifies the disposition of the dataset for abnormally terminated jobs (jobs ending with a system abend). The values for abnormal-disposition are the same as normal-disposition except that PASS is not allowed. abnormal-disposition defaults to the value of normal-disposition.
- LABEL
- specifies the file number and type of label for a tape data set. In addition, the LABEL parameter may also specify how a dataset is to be processed (input or output). The default for LABEL is LABEL=(1,SL).
- file
- specifies a number describing the dataset's position relative to other datasets on the tape.
- label-type
- includes SL for IBM Standard labels, AL for ANSI Standard labels, NL for no labels, and BLP for bypass label processing.
- processing-type
- may be either IN or OUT. IN specifies that a dataset is to be processed for input only. OUT specifies that a dataset is to be processed for output only.
- SPACE
- specifies disk space for a dataset.
- type
- is the unit of space and may be CYL (cylinders), TRK (tracks), or bytes per block. There are 15 tracks per cylinder, and 56,664 bytes per track.
- primary
- is the amount of space to be initially allocated for the dataset.
- secondary
- is the amount of additional space to be reserved if the primary allocation is not enough. The amount specified by secondary will be added to the amount specified by primary up to fifteen times if there is sufficient space on the volume.
- For example, SPACE=(TRK,(5,10)) requests a maximum of 5+15(10)=155 tracks for a sequential dataset.
- directory-blocks
- is the number of directory blocks to be used by a partitioned data set (PDS); directory-blocks is omitted for a sequential dataset. A good rule of thumb is to specify one directory block for every six members in a PDS.
- The RLSE parameter frees any unused space after a job has completed; unused space is not released if this parameter is omitted.
- UNIT
- specifies whether the dataset is to reside on disk or tape; device can be DISK for disk datasets, TAPE for cartridge tape datasets, or REEL for reel (round) tape datasets.
- VOL=SER
- specifies the volume on which the dataset resides; name is either a disk pack or a tape name. This parameter can be omitted for an existing catalogued data set. If VOL=SER=name is omitted for a NEW disk data set, name defaults to a public scratch pack; a dataset on this type of pack will be deleted in 48 hours if the dataset is less than 6 cylinders or 24 hours if the data set is bigger than 6 cylinders. The VOL=SER=name must be specified for tape datasets.
- In a multiple step job where a tape is to be accessed in several steps you should use the following format:
VOL=(,RETAIN,SER=name)
- The RETAIN parameter prevents the dismounting of a tape that will have to be remounted during a later job step.
Special DD Statements
- JOBLIB DD
- defines a private library that is searched first for a program specified on the EXEC PGM= statement. It is placed immediately after the JOB statement and is effective for all job steps.
- STEPLIB DD
- defines a private library that is searched first for a program specified on the EXEC PGM= statement. It is placed immediately after the EXEC statement, is effective only for that job step, and overrides the JOBLIB DD statement.
- SYSUDUMP DD
- is used to produce a dump of the processing storage area of the job step involved at abend time.
- SYSABEND DD
- produces a larger, more detailed dump than a SYSUDUMP DD statement and should be used only for system abends.
- SYSIN DD
- specifies a DDNAME for the input data statement in a job step. If a catalogued procedure is invoked and no SYSIN DD statement is provided, a SYSIN DD statement is generated automatically. The generated SYSIN DD statement applies to the first step of the catalogued procedure. Therefore, when invoking a one-step catalogued procedure, no SYSIN DD statement is necessary.
Examples:
The following statement indicates that the data follows immediately.
//SYSIN DD *
The data following this statement is input into the compile step.
//C.SYSIN DD *
The following statement indicates that data follows immediately. The DLM parameter informs the system that the /* is replaced by an AA as an indicator of the end of the input; the delimiter reverts to /* upon encountering an AA in positions 1 and 2 of a data record.
//SYSIN DD DATA,DLM=AA
The following DD statement specifies an output dataset, the contents of which are written onto regular computer paper.
//SYSPRINT DD SYSOUT=A
This is an example of a data definition statement that creates a partitioned dataset named USER.PROG.LIB.
//NEWNAME DD DSN=USER.PROG.LIB,DISP=(NEW,CATLG,DELETE),
// UNIT=DISK,DCB=(BLKSIZE=6320,LRECL=80,RECFM=FB),
// SPACE=(CYL,(1,1,1),RLSE)
The DISP parameter specifies that this is a NEW dataset and is either catalogued upon successful completion of the job or deleted upon abend. UNIT=DISK states that this dataset is to be created on disk. The DCB parameters describe characteristics of the data set, in this case card image form. The SPACE command specifies one cylinder of primary space, one cylinder of secondary space, and one directory block. RLSE frees any unused space.
The following DD statement describes a dataset named USER.ONE. The dataset has been previously catalogued and DISP=SHR permits the data set to be shared (read concurrently by more than one job).
//SYSUT1 DD DSN=USER.ONE,DISP=SHR
In the following DD statement, a new dataset named QBIV.ROOK is to be created as the first file on standard labeled tape T00000.
//NEWNAME DD DSN=QBIV.ROOK,DISP=(NEW,KEEP),UNIT=TAPE,
// VOL=SER=T00000,LABEL=(1,SL)
Note: Any job that uses a tape must have a JOBPARM statement requesting a tape drive; otherwise, the job will abend..
// Statement
The // statement signifies the end of a job.