Job Control Language
From Wikipedia, the free encyclopedia
Job Control Language (JCL) is a scripting language used on IBM mainframe operating systems to instruct the Job Entry Subsystem (that is, JES2 or JES3) on how to run a batch program or start a subsystem.
JCL is characterized by a pair of slashes "//" that indicate the start of each statement. The slashes date back from when punched cards were used to submit JCL code for execution. If the cards were mistakenly put back to front in the reader the slashes wouldn't be read first (instead, the sequence numbers would be), so the card deck could be rejected.
For backward compatibility, the basic syntax of JCL for z/OS hasn't changed since the 1960s. It is the same as JCL for OS/360.
DOS/VSE also has a JCL language. Its syntax is entirely different, the only similarity being that statements still start with two slashes: "//".
Contents |
[edit] Syntax
A JCL statement consists of one or more 80-byte records.
JCL must be in uppercase.
JCL must be in columns 1–71 (except comments, see below). Often columns 73–80 are used for sequence numbers.
To continue a line longer than 71 characters (except comments, see below), the first line is finished after a comma, and the next line started between columns 4 and 16 (with the usual "//" in the first two columns).
[edit] Identifier field
JCL starts with a "//" in columns 1–2, except:
- "/*" or another delimiter defined by the user
- "//*" which signifies the entire line is a comment
COMPONENTS OF JCL STATEMENTS JCL STATEMENTS CONSISTS OF FIVE TYPE OF FIELDS
1. // TWO FORWARDS SLASHES, IN COLUMNS 1 & 2.
2. NAME FIELD OPTIONAL FIELD, IF CODED MUST FOLLOW IMMEDIATELY AFTER THE "//", IN COLUMN 3.
3. OPERATION FIELD INDICATES THE OPERATION IS TO PERFORMED.
4. OPERAND FIELD THIS SHOULD APPEAR ONE OR MORE SPACES AFTER THE OPERATION FIELD.
5. COMMENTS PLACED ONE SPACE AFTER THE LAST OPERAND.
[edit] Name field
The name field identifies a statement so that other statements can refer to it. This must begin in column 3 and be from 1 to 8 characters long. Only uppercase alphabetics, numbers, or "national" characters ("#", "@", and "$") may be used. The name may not begin with a number...
[edit] Operation field
It must contain any one of the following operational fields:
- JOB
- EXEC
- DD
- PROC
- PEND
[edit] Parameter or operand field
Keyword parameters (THING=STUFF) may appear in any order, after any positional parameters; most of them are optional. There must be no spaces between parameters, or what follows will be interpreted as a comment (spacing in examples has been left for readability). Must be preceded by at least one blank.
[edit] Comments field
Comments on the same line as JCL statements follow the parameter field, and are separated from it by at least one blank.
To continue comments which would exceed column 71, non-blank is coded in column 72 ("X" is a de-facto standard), followed by "//" in columns 1–3 of the next line.
[edit] Jobs
Every 'Job' starts with a JOB statement and ends with an empty "//" card image. Each 'Step' within a 'Job' has one EXEC statement and any number of DD (data definition) statements, one for each dataset accessed. The following is a brief description of these, and a few other JCL statements. Jobname, stepname, progname, procstepname, procname and ddname are from 1 to 8 alpha-numeric characters, starting with an alphabetic character. Some installations may have further restrictions, especially about jobnames. Not all parameters have been described. //./
[edit] JOB
//jobname JOB (accounting information),CLASS=x,MSGCLASS=x,REGION=nK,TIME=(m,s),notify=&sysuid,TYPRUN=z
Accounting information is installation-dependent, and may be enclosed between brackets or quotation marks. It is typically used for charging departments according to CPU and I/O use.
The CLASS parameter determines in which 'initiator' the job will run, and determines default values for region-size, priority, maximum CPU time allowed, etc.
The MSGCLASS parameter determines how job output is to be printed or filed.
The REGION parameter specifies the maximum amount of virtual storage that the job may use. An amount of K or M may be specified, within installation limits specified by the job-class.
The TIME parameter specified the maximum total CPU usage (in minutes, seconds) that may be used by all steps of the job. The maximum allowed is normally 1439 minutes — the value 1440 means that the job will not be timed.
A user can be notified of the finish of the job via the "NOTIFY" field.
The TYPRUN parameter can have one of the following values: SCAN, HOLD, or COPY, and controls the type of execution for the job. SCAN checks for syntax errors but does not execute the job; HOLD checks the job for syntax errors and will hold the job in the input queue if it finds none it will not execute unless next command from user to do so (release command); for COPY no syntax checking or execution takes place - the source content is passed directly to the output queue.
[edit] EXEC PGM
//stepname EXEC PGM=progname,PARM='parm',COND=condition,REGION=n,TIME=(m,s)
Progname is the name of the program to be executed. If JOBLIB or STEPLIB were specified, the program will be sought in the libraries specified in DD statements prior to standard 'linklist' libraries (see below).
The PARM parameter is optionally used to pass data to the program. At program execution time, register 1 points to a parameter list.
The COND parameter specifies those conditions under which the job step is to be skipped, and NOT run. Its counter-intuitive syntax often causes confusion and has been replaced by IF statements in recent releases of the operating system.
REGION and TIME parameters are as for the JOB statements but apply to a single job-step.
[edit] EXEC PROC
//procstepname EXEC PROC=procname,param1=foo, ...
or
//procstepname EXEC procname,param1=foo, ...
Procname is either the name of a catalogued or in-stream procedure (see below). The values of param1, etc. depend on what symbolic keywords are defined in the procedure. Procedures are collections of predefined JCLs.
NOTE: In practice, it is far more common to use the second form ("EXEC procname") and to omit the "PROC=" keyword.
[edit] DD
//ddname DD DSN=datasetname,DISP=disposition,UNIT=unit,VOL=SER/volser,SPACE=space,DSORG=dsorg,DCB=dcb
or
//ddname DD *
or
//ddname DD DATA,DLM=@@
or
//ddname DD SYSOUT=msgclass
In the DSN parameter, datasetname is the name of the dataset to be accessed or allocated. If it is not catalogued, then UNIT (and VOL) parameters must be supplied. Sub parameters used with VOL parameter
SER - Specification of serial number REF - Referencing VOL specification from a prior step PRIVATE - Allowing access to volume by single user RETAIN - Inhibiting dismounting of volume until end of job SEQ - Specification of sequence in which volumes are to be mounted A member of a partitioned dataset is referred to by enclosing the member-name in parentheses; e.g. MY.LIBRARY(MYPROGRM). If a datasetname is not supplied, the system will provide one; this can only be used for files that will not be kept beyond this step. To allocate a temporary dataset to be passed to further jobsteps but not then kept, use DSN=&&TEMPNAME, for example.
The DISP parameter specifies whether the dataset is to be created or whether it already exists, and whether it is to be kept or deleted after the job-step finishes (either successfully or unsuccessfully). The disposition consists of up to three sub-parameters in brackets. Some examples:
DISP=(OLD,DELETE,KEEP) already exists, is to be deleted unless the step fails DISP=SHR already exists and other tasks may read it at the same time DISP=(NEW,CATLG,DELETE) will be created and catalogued unless the step fails
The default, if not specified, is (NEW,DELETE).
[edit] PARAMETERS ON DISP STATEMENT
STATUS | NORMAL DISPOSITION | ABNORMAL DISPOSITION |
---|---|---|
NEW | DELETE | DELETE |
OLD | KEEP | KEEP |
MOD | CATLG | UNCATLG |
SHR | UNCATLG | CATLG |
PASS |
The UNIT and VOL parameters can be quite complex, but here are two simple examples:
UNIT=SYSDA any system direct access device (normally for temporary files) UNIT=3390,VOL=SER=ABC123 allocate on a specific DASD pack
The SPACE parameter specifies the primary and secondary space allocation (in blocks, tracks or cylinders) and the number of directory blocks for a partitioned dataset. Some examples:
SPACE=(TRK,1) just 1 track and no secondaries SPACE=(CYL,(50,25)) 50 cylinders of space plus up to 15 times 25 cylinders of secondary SPACE=(4096,(10000),ROUND,RLSE) space equivalent to 10,000 blocks, each of 4,096 bytes, rounded to the nearest cylinder size, and unused space released at the end of the job-step.
The DSORG parameter specifies the dataset organization of the dataset. Some possibilities are PS (physical sequential), DA (direct access), IS (ISAM - no longer supported) and PO (partitioned).
The DCB parameter specifies any sub-parameter that a program could specify in its Data Control Block for this DD statement. A common possibility is RECFM (Record format - FB (fixed, blocked), U (undefined), etc.).
DD * is followed by data in the form of 80-byte card images, and the data stream is terminated with a card image having /* in the first two columns (or the next JCL statement).
DD DATA is the same, but may contain JCL statements. It is terminated by a card having @@ in the first two columns (or by the end of the JCL).
DD SYSOUT=msgclass is used for printed output. Specifying SYSOUT=* will result in using the MSGCLASS of the JOB card.
DD statements used for input may be concatenated as follows.
//STEPLIB DD DSN=MY.TEST.LIBRARY,DISP=SHR // DD DSN=MY.TEAM.LIBRARY,DISP=SHR // DD DSN=MY.LIVE.LIBRARY,DISP=SHR
[edit] Procedures
Procedures are JCL skeletons that normally have such things as dataset names replaced by symbols. These symbolic names are then resolved to real names when the procedure is used. Procedures provide a macro ability to JCL.
In older versions of MVS, procedures could only be cataloged to SYS1.PROCLIB and this is still used as a default. Later versions added support for user-defined procedure libraries.
While procedures are normally executed from a procedure library (known as a proclib), they can also be defined within the job that executes them. These are known as inline procedures and this is the usual method for testing them before adding them to a proclib.
The first line is always a PROC statement. It names the procedure and defines any default values for symbolic entries, e.g.
//MYPROC PROC &LIB="MY.TEST.LIBRARY"
A job could then call up this procedure as follows:
//FIRST EXEC MYPROC //SECOND EXEC MYPROC,LIB="FREDS.TEST.LIBRARY"
For inline testing the procedure is included first, and is terminated by . .
// PEND
[edit] Conditional processing
JCL supports rudimentary conditional processing with if-then-else-endif statements:
//TESTCOND IF (RC = 8 | RC = 10) THEN … //ELSECOND ELSE … //ENDCOND ENDIF
[edit] Example
Because of its heritage, operations in JCL are often more complex than in other operating systems. The following example shows the JCL statements necessary to copy an existing dataset (IS198.TEST.INPUT) to a new dataset (IS198.TEST.OUTPUT).
//IS198CPY JOB (IS198T30500),'COPY JOB',CLASS=L,MSGCLASS=X //COPY01 EXEC PGM=IEBGENER //SYSPRINT DD SYSOUT=* //SYSUT1 DD DSN=IS198.TEST.INPUT,DISP=SHR //SYSUT2 DD DSN=IS198.TEST.OUTPUT, // DISP=(NEW,CATLG,DELETE), // SPACE=(CYL,(40,5),RLSE), // DCB=(LRECL=115,BLKSIZE=0), // DATACLAS=SEQFB //SYSIN DD DUMMY
IEBGENER is the program being called, a utility to copy datasets. The SYSPRINT DD defines where to send the results of the operation, SYSUT1 the input dataset, and SYSUT2 the output dataset.
Note how the size (SPACE=) and attributes (DCB=, DATACLAS=) of the output dataset have to be specified by the operator (alternatively, JCL can be told to model this from an existing dataset).