Job Control Language
Job Control Language is a programming language for scripting and launching batch jobs on IBM mainframe computers. JCL code determines which programs to run, and with which files and devices for input and output. Parameters in the JCL can also provide accounting information for tracking the resources used by a job and can set which machine the job should run on.
There are two major variants based on host platform and associated lineage. One version is available on the platform lineage that starts with DOS/360 and has progressed to z/VSE. The other version starts with OS/360 and continues to z/OS which includes JES extensions, Job Entry Control Language. The variants share basic syntax and concepts but have significant differences. The VM operating system does not have JCL as such; the CP and CMS components each have command languages.
Generically, a job control language is any programming language for job control; not just the IBM mainframe one.
Terminology
JCL-specific terminology includes:; Data set
A file, either temporary or permanent; it may be located on a disk drive, tape storage, or another device.
; Partitioned data set
A collection of files; a PDS is commonly used to store textual data such as source code, assembler macros, system configuration, reusable JCL procedures, etc. As a collection of files, a PDS is like to an archive file which in turn is like a file system directory. A PDS can contain executable code which makes a PDS like a Unix-based static library. A member, once stored, cannot be updated although a member can be deleted and replaced, such as via the IEBUPDTE utility. Since the 1989 release of MVS DFP 3.2, an enhanced version, partitioned data set extended has been available.
; Member
A file in a PDS. A member can be accessed by specifying the name of the PDS with the member name in parentheses. For example, the system macro GETMAIN in SYS1.MACLIB can be referenced as.
; Unix system services
A complete Unix environment running as part of the MVS base control program. It allows Unix files, scripts, tasks, and programs to run on a mainframe in a POSIX-compliant Unix environment without virtualization.
Motivation
Originally, mainframe systems were oriented toward batch processing. Many batch jobs require setup, with specific requirements for main storage, and dedicated devices such as magnetic tapes, private disk volumes, and printers set up with special forms. JCL was developed as a means of ensuring that all required resources are available before a job is scheduled to run. For example, many systems, such as Linux allow identification of required datasets to be specified on the command line, and therefore subject to substitution by the shell, or generated by the program at run-time.On these systems the operating system job scheduler has little or no idea of the requirements of the job. In contrast, JCL explicitly specifies all required datasets and devices. The scheduler can pre-allocate the resources prior to releasing the job to run. This helps to avoid "deadlock", where job A holds resource R1 and requests resource R2, while concurrently running job B holds resource R2 and requests R1. In such cases the only solution is for the computer operator to terminate one of the jobs, which then needs to be restarted. With job control, if job A is scheduled to run, job B will not be started until job A completes or releases the required resources.
Features common to DOS and OS JCL
Jobs, steps and procedures
For both DOS and OS the unit of work is the job. A job consists of one or several steps, each of which is a request to run one specific program. For example, before the days of relational databases, a job to produce a printed report for management might consist of the following steps: a user-written program to select the appropriate records and copy them to a temporary file; sort the temporary file into the required order, usually using a general-purpose utility; a user-written program to present the information in a way that is easy for the end-users to read and includes other useful information such as sub-totals; and a user-written program to format selected pages of the end-user information for display on a monitor or terminal.In both DOS and OS JCL the first "card" must be the JOB card, which:
- Identifies the job.
- Usually provides information to enable the computer services department to bill the appropriate user department.
- Defines how the job as a whole is to be run, e.g. its priority relative to other jobs in the queue.
Basic syntax
Both DOS and OS JCL have a maximum usable line length of 80 characters, because when DOS/360 and OS/360 were first used the main method of providing new input to a computer system was 80-column punched cards. It later became possible to submit jobs via disk or tape files with longer record lengths, but the operating system's job submission components ignored everything after character 80.Strictly speaking both operating system families use only 71 characters per line. Characters 73-80 are usually card sequence numbers which the system printed on the end-of-job report and are useful for identifying the locations of any errors reported by the operating system. Character 72 is usually left blank, but it can contain a nonblank character to indicate that the JCL statement is continued onto the next card.
All commands, parameter names and values have to be in capitals, except for USS filenames.
All lines except for in-stream input have to begin with a slash "
/", and all lines which the operating system processes have to begin with two slashes // - always starting in the first column. However, there are two exceptions: the delimiter statement and the comment statement. A delimiter statements begins with a slash and an asterisk, and a comment statement in OS JCL begins with a pair of slashes and asterisk or an asterisk in DOS JCL.Many JCL statements are too long to fit within 71 characters, but can be extended on to an indefinite number of continuation cards by:
| OS JCL | DOS JCL |
| Ending all actual JCL cards except the last at a point where the syntax requires a comma | Ending all actual JCL cards except the last at a point where the syntax requires a comma and a non-blank character in column 72 |
Starting each continuation card with // in column 1 and then at least 1 space | Starting each continuation card with spaces and continuing in column 15 |
The structure of the most common types of card is:
| OS JCL | DOS JCL |
| // // with a space between. |
In-stream input
DOS and OS JCL both allow in-stream input, i.e. "cards" which are to be processed by the application program rather than the operating system. Data which is to be kept for a long time will normally be stored on disk, but before the use of interactive terminals became common the only way to create and edit such disk files was by supplying the new data on cards.DOS and OS JCL have different ways of signaling the start of in-stream input, but both end in-stream input with
/* at column 1 of the card following the last in-stream data card. This makes the operating system resume processing JCL in the card following the /* card.- OS JCL: DD statements can be used to describe in-stream data, as well as data sets. A DD statement dealing with in-stream data has an asterisk following the DD identifier, e.g.
//SYSIN DD *. JCL statements can be included as part of in-stream data by using the DD DATA statements.
//SUBM EXEC PGM=IEBGENER
//SYSPRINT DD SYSOUT=Z
//SYSUT2 DD SYSOUT=
//SYSIN DD DUMMY
//SYSUT1 DD DATA,DLM=ZZ
//RUNLATR JOB ACCT,MANIX,CLASS=A.TYPRUN=HOLD
//* ^ a JOB to run later
//CPUHOG EXEC PGM=PICALC1K
//OUTPUT DD DSN=PICALC.1000DGTS,SPACE=,DISP=
ZZ
//* ^ as specified by DLM=ZZ
//DROPOLDR EXEC PGM=IEFBR14
//DELETE4 DD DSN=PICALC.4DGTS,DISP=
//DELETE5 DD DSN=PICALC.5DGTS,DISP=
- DOS JCL: Simply enter the in-stream data after the EXEC card for the program.
Complexity
Much of the complexity of OS JCL, in particular, derives from the large number of options for specifying dataset information. While files on Unix-like operating systems are abstracted into ordered streams of bytes, with the task of reading and writing structured data belonging exclusively with user-level programs, and the practical details of data storage and access handled in large part by the operating system without the knowledge of user programs; datasets on OS/360 and its successors expose their file types and sizes, record types and lengths, block sizes, device-specific information like magnetic tape density, and label information. Although there are system defaults for many options, there is still a lot to be specified by the programmer, through a combination of JCL and information coded in the program. The more information coded in the program, the less flexible it is, since information in the program overrides anything in the JCL; thus, most information is usually supplied through JCL.
For example, to copy a file on Unix operating system, the user would enter a command like:
cp oldFile newFile
The following example, using JCL, might be used to copy a file on OS/360:
//IS198CPY JOB,'COPY JOB',CLASS=L,MSGCLASS=X
//COPY01 EXEC PGM=IEBGENER
//SYSPRINT DD SYSOUT=*
//SYSUT1 DD DSN=OLDFILE,DISP=SHR
//SYSUT2 DD DSN=NEWFILE,
// DISP=,
// SPACE=,
// DCB=
//SYSIN DD DUMMY
A second explanation for the complexity of JCL is the different expectations for running a job from those found in a PC or Unix-like environment.
- Low-end System/360 CPUs were less powerful and more expensive than the mid-1980s PCs for which MS-DOS was designed. OS/360 was intended for systems with a minimum memory size of 32 KB and DOS/360 for systems with a minimum of 16 KB. A 360/30 CPU—low-end when System/360 was announced in 1964—processed 1.8K to 34.5K instructions per second. The first IBM PC in 1981 had 16 KB or 64 KB of memory and would process about 330K instructions per second. As a result, JCL had to be easy for the computer to process, and ease of use by programmers was a much lower priority. In this era, programmers were much cheaper than computers.
- JCL was designed for batch processing. As such, it has to tell the operating system everything, including what to do depending on the result of a step. For example,
DISP=means "if the program runs successfully, create a new file and catalog it; otherwise delete the new file." Programs run on a PC frequently depend on the user to clean up after processing problems. - System/360 machines were designed to be shared by all the users in an organization. So the
JOBcard tells the operating system how to bill the user's account, what predefined amount of storage and other resources may be allocated, and several other things.tells the computer to print the program's report on the default printer which is loaded with ordinary paper, not on some other printer which might be loaded with blank checks.DISP=SHRtells the operating system that other programs can readOLDFILEat the same time.
The syntax of OS JCL is similar to the syntax of macros in System/360 assembly language, and would therefore have been familiar to programmers at a time when many programs were coded in assembly language.