Job Control Language
Encyclopedia
Job Control Language is a scripting language
Scripting language
A scripting language, script language, or extension language is a programming language that allows control of one or more applications. "Scripts" are distinct from the core code of the application, as they are usually written in a different language and are often created or at least modified by the...

 used on IBM mainframe
IBM mainframe
IBM mainframes are large computer systems produced by IBM from 1952 to the present. During the 1960s and 1970s, the term mainframe computer was almost synonymous with IBM products due to their marketshare...

 operating systems to instruct the system on how to run a batch job
Batch processing
Batch processing is execution of a series of programs on a computer without manual intervention.Batch jobs are set up so they can be run to completion without manual intervention, so all input data is preselected through scripts or command-line parameters...

 or start a subsystem.

There are actually two IBM JCLs: one for the operating system lineage that begins with DOS/360
DOS/360
Disk Operating System/360, also DOS/360, or simply DOS, was an operating system for IBM mainframes. It was announced by IBM on the last day of 1964, and it was first delivered in June 1966....

 and whose latest member is z/VSE; and the other for the lineage from OS/360 to z/OS
Z/OS
z/OS is a 64-bit operating system for mainframe computers, produced by IBM. It derives from and is the successor to OS/390, which in turn followed a string of MVS versions.Starting with earliest:*OS/VS2 Release 2 through Release 3.8...

. They share some basic syntax rules and a few basic concepts, but are otherwise very different.

Jobs, steps and procedures

In both JCLs 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 database
Relational database
A relational database is a database that conforms to relational model theory. The software used in a relational database is called a relational database management system . Colloquial use of the term "relational database" may refer to the RDBMS software, or the relational database itself...

s, 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
Sorting algorithm
In computer science, a sorting algorithm is an algorithm that puts elements of a list in a certain order. The most-used orders are numerical order and lexicographical order...

 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.


Procedures (commonly called procs) are pre-written JCL for steps or groups of steps, inserted into a job. Both JCLs allow such procedures. Procs are used for repeating steps which are used several times in one job, or in several different jobs. They save programmer time and reduce the risk of errors. To run a procedure one simply includes in the JCL file a single "card" which copies the procedure from a specified file, and inserts it into the jobstream. Also, procs can include parameters to customize the procedure for each use.

Basic syntax

Both DOS and OS JCL have a maximum usable line length of 80 characters, because when DOS/360
DOS/360
Disk Operating System/360, also DOS/360, or simply DOS, was an operating system for IBM mainframes. It was announced by IBM on the last day of 1964, and it was first delivered in June 1966....

 and OS/360 were first used the main method of providing new input to a computer system was 80-column punched card
Punched card
A punched card, punch card, IBM card, or Hollerith card is a piece of stiff paper that contains digital information represented by the presence or absence of holes in predefined positions...

s. 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 to separate the real JCL from any sequence numbers, but in OS JCL it can contain a continuation character for comments.

All commands, parameter names and values have to be in capitals, except for USS
UNIX System Services
UNIX System Services is a required, included component of z/OS. USS is a certified UNIX implementation optimized for mainframe architecture. It is the first UNIX 95 to not be derived from the AT&T source code...

 filenames.

All lines except for in-stream input (see below) 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 begins with a pair of slashes and asterisk (//*).

Many JCL statements are too long to fit within 71 characters, but can be extended on to an indefinite number of continuation cards by:
  • Ending all actual JCL cards except the last at a point where the syntax requires a comma ",".
  • Starting each continuation card with "//" in column 1 and then at least 1 space.


The structure of the most common types of card is:
  • "//"
  • Name of whatever the card applies to, following "//" with no space between.
  • Space(s)
  • Statement type
  • Space(s)
  • Parameters which vary depending on the statement type, separated by commas and with no space between them.

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.

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. JCL statements can be included as part of in-stream data by using the DD DATA statements.

Complexity

This is best illustrated by a simple example. To copy a file
File copying
In the realm of computer file management, file copying is the creation of a new file which has the same content as an existing file.All computer operating systems include file copying provisions in the user interface, like the command, "cp" in Unix and "copy" in MS-DOS; operating systems with a...

 in MS-DOS
MS-DOS
MS-DOS is an operating system for x86-based personal computers. It was the most commonly used member of the DOS family of operating systems, and was the main operating system for IBM PC compatible personal computers during the 1980s to the mid 1990s, until it was gradually superseded by operating...

 one simply types in a command like
copy oldFile newFile

In the OS/360 family one would use something like
//IS198CPY JOB (IS198T30500),'COPY JOB',CLASS=L,MSGCLASS=X
//COPY01 EXEC PGM=IEBGENER
//SYSPRINT DD SYSOUT=*
//SYSUT1 DD DSN=OLDFILE,DISP=SHR
//SYSUT2 DD DSN=NEWFILE,
// DISP=(NEW,CATLG,DELETE),
// SPACE=(CYL,(40,5),RLSE),
// DCB=(LRECL=115,BLKSIZE=1150)
//SYSIN  DD DUMMY
Dummy
Dummy may refer to:*Military dummy:**dummy round—a cartridge that is inert, i.e. contains neither primer nor gunpowder**decoy—fake military equipment intended to deceive the enemy...



Some of the complexity is due to poor design - but quite a lot of the complexity is due to the environment in which JCL was expected to be used:
  • Low-end System/360
    System/360
    The IBM System/360 was a mainframe computer system family first announced by IBM on April 7, 1964, and sold between 1964 and 1978. It was the first family of computers designed to cover the complete range of applications, from small to large, both commercial and scientific...

     CPUs were much less powerful and vastly more expensive than the mid-1980s PCs for which MS-DOS was designed. OS/360 was intended for systems with a minimum of 32 KB memory and DOS/360
    DOS/360
    Disk Operating System/360, also DOS/360, or simply DOS, was an operating system for IBM mainframes. It was announced by IBM on the last day of 1964, and it was first delivered in June 1966....

     for systems with a minimum of 16 KB; and a 360/30 CPU (low-end when System/360 was announced in 1964) processed a mere 5K to 13K instructions per second. The first IBM PC
    IBM PC
    The IBM Personal Computer, commonly known as the IBM PC, is the original version and progenitor of the IBM PC compatible hardware platform. It is IBM model number 5150, and was introduced on August 12, 1981...

     (model 5150 in 1981) had 16KB or 64KB of memory and would process about 330,000 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
    Batch processing
    Batch processing is execution of a series of programs on a computer without manual intervention.Batch jobs are set up so they can be run to completion without manual intervention, so all input data is preselected through scripts or command-line parameters...

    , often by a computer in a different building from the user's office. So it has to tell the operating system everything, including what to do depending on the result of the step. For example DISP=(NEW,CATLG,DELETE) means "if the program runs successfully, create a new file and catalog it; otherwise delete the new file."
  • System/360 machines were designed to be shared by all the users in an organization. So the JOB card tells the operating system how to bill the users (account IS198T30500), what priority the job has relative to other users' jobs (CLASS=L), 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=SHR tells the operating system that other programs can read OLDFILE at the same time
    Multiprogramming
    Computer multiprogramming is the allocation of a computer system and its resources to more than one concurrent application, job or user ....

    .


Despite these difficulties IBM considered it necessary to retain all the features of the original JCLs, to avoid forcing customers to rewrite all their JCL files. But it later introduced easier alternatives such as CLIST
CLIST
CLIST is a procedural programming language for TSO in MVS systems. It originated in OS/360 Release 20 and has assumed a secondary role since the availability of Rexx in TSO/E Version 2....

. And of course most users save as a procedure any set of JCL statements which is likely to be used more than once or twice.

Positional parameters

// TLBL TAPEFIL,'COPYTAPE.JOB',,,,2
// ASSGN SYS005,DISK,VOL=VOL01,SHR
// DLBL DISKFIL,'COPYTAPE.JOB',0,SD
// EXTENT SYS005,VOL01,1,0,800,1600

In DOS JCL parameters are positional, which makes them harder to read and write:
  • The programmer must remember which item goes in which position in every type of statement.
  • If some optional parameters are omitted but later ones are included, the omitted parameters must be represented by commas with no spaces, as in the TLBL statement above.


DOS JCL to some extent mitigates the difficulties of positional parameters by using more statements with fewer parameters than OS JCL. In the example the ASSGN, DLBL and EXTENT statements do the same work (specifying where a new disk file should be stored) as a single DD statement in OS JCL.

Device dependence

In the original DOS/360
DOS/360
Disk Operating System/360, also DOS/360, or simply DOS, was an operating system for IBM mainframes. It was announced by IBM on the last day of 1964, and it was first delivered in June 1966....

 and in most versions of DOS/VS one had to specify the model number of the device which was to be used for each disk or tape file - even for existing files and for temporary files which would be deleted at the end of the job. This meant that, if a customer upgraded to a more modern type of device, many JCL files had to be changed.

Later members of the DOS/360 family reduced the number of situations in which model numbers were required.

OS JCL

OS JCL consists of only 3 basic statements:
  • JOB statement, which identifies the start of the job, and information about the whole job, such as billing, run priority, and time & space limits.
  • EXEC statement, which identifies the program to be executed in this step of the job, and information about the step.
  • DD (Data Description) statements, which identify a data file to be used in a step, and detailed info about that file. DD statements can be in any order within the step.


Right from the start JCL for the OS family (up to and including z/OS
Z/OS
z/OS is a 64-bit operating system for mainframe computers, produced by IBM. It derives from and is the successor to OS/390, which in turn followed a string of MVS versions.Starting with earliest:*OS/VS2 Release 2 through Release 3.8...

) was more flexible and easier to use.

The examples below use the old style of syntax which was provided right from the launch of System/360
System/360
The IBM System/360 was a mainframe computer system family first announced by IBM on April 7, 1964, and sold between 1964 and 1978. It was the first family of computers designed to cover the complete range of applications, from small to large, both commercial and scientific...

 in 1964. The old syntax is still quite common in jobs which have been running for over 20 years with only minor changes - these old jobs are often complex, and converting them to use the CLIST
CLIST
CLIST is a procedural programming language for TSO in MVS systems. It originated in OS/360 Release 20 and has assumed a secondary role since the availability of Rexx in TSO/E Version 2....

 syntax would be tricky and time-consuming.

Although the CLIST syntax is easier to read, programmers still have to provide the same amount of information as they would using the old syntax.

Keyword parameters

//NEWFILE DD DSN=MYFILE01,UNIT=DISK,SPACE=(TRK,80,10),
// DCB=(LRECL=100,BLKSIZE=1000),
// DISP=(NEW,CATLG,DELETE)
All of the major parameters of OS JCL statements are identified by keywords and can be presented in any order. A few of these contain 2 or more sub-parameters, like SPACE (how much disk space to allocate to a new file) and DCB (detailed specification of a file's layout) in the example above. Sub-parameters are sometimes positional, as in SPACE, but the most complex parameters, such as DCB, have keyword sub-parameters.

Positional parameter must precede keyword parameters. Keyword parameters always assign values to a keyword using the equals sign (=).

Device independence

From the very beginning the JCL for the OS family of operating systems offered a high degree of device independence. Even for new files which were to be kept after the end of the job one could specify the device type in generic terms, e.g. UNIT=DISK or UNIT=TAPE. Of course if it mattered one could specify a model number or even a specific device address.

Parameterized procedures

OS JCL procedures were parameterized from the start, making them rather like macros or even simple subroutine
Subroutine
In computer science, a subroutine is a portion of code within a larger program that performs a specific task and is relatively independent of the remaining code....

s and thus increasing their reusability
Code reuse
Code reuse, also called software reuse, is the use of existing software, or software knowledge, to build new software.-Overview:Ad hoc code reuse has been practiced from the earliest days of programming. Programmers have always reused sections of code, templates, functions, and procedures...

 in a wide range of situations.
//MYPROC PROC FNAME=MYFILE01,SPTYPE=TRK,SPINIT=50,SPEXT=10,LR=100,BLK=1000
.....
//NEWFILE DD DSN=&FNAME,UNIT=DISK,SPACE=(&SPTYPE,&SPINIT,&SPEXT),
// DCB=(LRECL=&LR,BLKSIZE=&BLK),DISP=(NEW,CATLG,DELETE)
....
In this example all the values beginning with ampersands "&" are parameters which will be specified when a job requests that the procedure be used. The PROC statement, in addition to giving the procedure a name, allows the programmer to specify default values for each parameter. So one could use the one procedure in this example to create new files of many different sizes and layouts. For example:
//JOB01 JOB ..........
//STEP01 EXEC MYPROC FNAME=JOESFILE,SPTYPE=CYL,SPINIT=10,SPEXT=2,LR=100,BLK=2000
or
//JOB02 JOB ..........
//STEP01 EXEC MYPROC FNAME=SUESFILE,SPTYPE=TRK,SPINIT=500,SPEXT=100,LR=100,BLK=5000

Override capabilities

OS allows programmers to override in JCL some of the specifications of file structure which programs might contain. This facility is mostly used for creating new files. For example in
//STEP01 EXEC PGM=MYPROG
//NEWFILE DD DSN=MYFILE01,UNIT=DISK,SPACE=(TRK,50,10),DCB=BLKSIZE=1000,
// DISP=(NEW,CATLG,DELETE)
the new file will have a block size
Block (data storage)
In computing , a block is a sequence of bytes or bits, having a nominal length . Data thus structured are said to be blocked. The process of putting data into blocks is called blocking. Blocking is used to facilitate the handling of the data-stream by the computer program receiving the data...

 of 1000 bytes even if code in program MYPROG says the block size should be something else - so there's no need to change program MYPROG. On the other hand since this example does not specify the LRECL (record length) sub-parameter of DCB, the record length will be whatever MYPROG says.

Referbacks

In multi-step jobs, a later step can use a referback instead of specifying in full a file which has already been specified in an earlier step. For example in this procedure
//MYPROC ................
//MYPR01 EXEC PGM=..........
//NEWFILE DD DSN=&MYFILE,UNIT=DISK,SPACE=(TRK,50,10),
// DCB=(LRECL=100,BLKSIZE=1000),DISP=(NEW,CATLG,DELETE)
....
//MYPR02 EXEC PGM=..........
//INPUT01 DD DSN=*.MYPR01.NEWFILE
step MYPR02 uses the file identified as NEWFILE in step MYPR01 (DSN means "dataset name" and specifies the name of the file).

In jobs which contain a mixture of job-specific JCL and procedure calls, a job-specific step can refer back to a file which was fully specified in a procedure, for example
//MYJOB JOB ..........
//STEP01 EXEC MYPROC Using a procedure
//STEP02 EXEC PGM=......... Step which is specific to this job
//INPUT01 DD DSN=*.STEP01.MYPR01.NEWFILE
where DSN=*.STEP01.MYPR01.NEWFILE means "use the file identified as NEWFILE in step MYPR01 of the procedure used by step STEP01 of this job". Using the name of the step which called the procedure rather than the name of the procedure allows a programmer to use the same procedure several times in the same job without confusion about which instance of the procedure is used in the referback.

Comments

JCL files can be long and complex, and the language is not easy to read. OS JCL allows programmers to include two types of explanatory comment:
  • On the same line as a JCL statement. They can be extended by placing a continuation character (usually "X") in column 72, followed by "// " in columns 1–3 of the next line.
  • Lines which contain only comment, often used to explain major points about the overall structure of the JCL rather than local details. Comment-only lines are also used to divide long, complex JCL files into sections.

//MYJOB JOB ..........
//* Lines containing only comments.
//******** Often used to divide JCL listing into sections ********
//STEP01 EXEC MYPROC Comment 2 on same line as statement
//STEP02 EXEC PGM=......... Comment 3 has been extended and X
// overflows into another line.
//INPUT01 DD DSN=STEP01.MYPR01.NEWFILE

Concatenating input files

OS JCL allows programmers to concatenate ("chain") input files so that they appear to the program as one file, for example
//INPUT01 DD DSN=MYFILE01,DISP=SHR
// DD DSN=JOESFILE,DISP=SHR
// DD DSN=SUESFILE,DISP=SHR
The 2nd and third statements have no value in the name field, so OS treats them as concatenations. The files must be of the same basic type (almost always sequential), and must have the same record length.

Conditional processing

OS expects programs to set a return code which specifies how successful the program thought it was. The most common conventional values are:
  • 0 = all OK
  • 4 = minor errors or problems
  • 8 = significant errors or problems
  • 12 = major errors or problems, the results (e.g. files or reports produced) should not be trusted.
  • 16 = very serious problems, do not use the results!


OS JCL refers to the return code as COND ("condition code"), and can use it to decide whether to run subsequent steps. However, unlike most modern programming languages, conditional steps in OS JCL are not executed if the specified condition is true—thus giving rise to the mnemonic
Mnemonic
A mnemonic , or mnemonic device, is any learning technique that aids memory. To improve long term memory, mnemonic systems are used to make memorization easier. Commonly encountered mnemonics are often verbal, such as a very short poem or a special word used to help a person remember something,...

, "If it's true, pass on through [without running the code]." To complicate matters further, the condition can only be specified after the step to which it refers. For example:
//MYJOB JOB ...........
//STEP01 EXEC PGM=PROG01
....
//STEP02 EXEC PGM=PROG02,COND=(4,GT,STEP01)
....
//STEP03 EXEC PGM=PROG03,COND=(8,LE)
....
//STEP04 EXEC PGM=PROG04,COND=(ONLY,STEP01)
....
//STEP05 EXEC PGM=PROG05,COND=(EVEN,STEP03)
....
means:
  1. Run STEP01, and collect its return code.
  2. Don't run STEP02 if the number 4 is greater than STEP01's return code.
  3. Don't run STEP03 if the number 8 is less than or equal to any previous return code.
  4. Run STEP04 only if STEP01 abnormally ended.
  5. Run STEP05, even if STEP03 abnormally ended.


This translates to the following pseudocode
Pseudocode
In computer science and numerical computation, pseudocode is a compact and informal high-level description of the operating principle of a computer program or other algorithm. It uses the structural conventions of a programming language, but is intended for human reading rather than machine reading...

:
run STEP01

if STEP01's return code is greater than or equal to 4 then
run STEP02
end if

if any previous return code is less than 8 then
run STEP03
end if

if STEP01 abnormally ended then
run STEP04
end if

if STEP03 abnormally ended then
run STEP05
else
run STEP05
end if

Note that by reading the steps containing COND statements backwards, one can understand them fairly easily. This is an example of logical transposition
Transposition (logic)
In the methods of deductive reasoning in classical logic, transposition is the rule of inference that permits one to infer from the truth of "A implies B" the truth of "Not-B implies not-A", and conversely. Its symbolic expression is:...

.
However, IBM later introduced IF condition in JCL thereby making coding somewhat easier for programmers while retaining the COND parameter (to avoid making changes to the existing JCLs where COND parm is used).

JCL utilities

JCL uses a number of IBM utility programs to assist in the processing of data. Utilities are most useful in batch processing. The utilities can be grouped into three sets:
(1) Data Set Utilities - to create, print, copy, move and delete data sets;
(2) System Utilities - to maintain and manage catalogs;
(3) Access Method Services - to process VSAM (Virtual storage access method) and non-VSAM data sets.
The source of this article is wikipedia, the free encyclopedia.  The text of this article is licensed under the GFDL.
 
x
OK