Mainframes 360
The one stop destination for System Z professionals

Thursday, January 21, 2010

The Structure of JCL


Q. What is Job Control Language?
Job Control Language(JCL) is used to tell the computer what programs to run, which files these programs will use, to read input data and write output data. 

Mainframes are different from your Windows PC, where you give an input command, and the computer  produces some output, then you give some more input, the computer produces another output and so on, this interactive input-process-output cycle continues, until all the processing is done and your task is completed. On the Windows PC, programs run in an online interactive mode. Generally there is only 1 user to a PC, and it provides immediate response(output) to a user Input.

On the other hand, millions of people send request, feed inputs to a Mainframe. Thus, Mainframes don’t like to talk to people interactively. Instead, Mainframes process your data in Batch Mode

Batch Mode means, that you need to tell the Mainframe, right at the start, what is the program you want to run, in which file the input data is stored, what will be the output files, everything right at the beginning, even before the Mainframe starts with your task. Specify the program, the input source files, the output destination files, before the program commences to run.

Once the Mainframe knows all the details about your task – Program to be run, Input files, Output files(to store results), error files etc., it accepts the task.  The task may take an indefinite amount of time to complete, the Mainframe schedules the task for a particular time, depending on which time-slot is available. Just like you, there would be millions of other guys, whose tasks have to be completed. On Mainframes, you would not get immediate output results(immediate service) on the spur of the moment(on the go). Instead, the Mainframe performs the task as per its convenience, and notifies you, alerts you, once your task is completed.
Q. Isn’t TSO/ISPF interactive? I give some input, and it immediately displays some output screen.
You might be tempted to think so, because you used TSO to deal interactively with a Mainframe via a 3270 terminal or PC. However, what you need to realize, is that, TSO itself is a program that’s being run on the Mainframe. It’s actually a Giant Word-Processor, that lets you key in(type in) your programs and Job Control Language into the computer. It actually converts your programs and JCL, into machine-readable form, an internal format which the MVS Operating System can understand. Thus, TSO is just a messenger/carrier to the MVS Operating System.

If you want to talk to the MVS Operating System, your messages, instructions or commands must be in a language called Job Control Language(JCL). JCL is the only way to talk and give instructions to the MVS Operating System!
Q. How does JCL execute Programs? 
A Program is sequence of instructions to the computer, that performs some task/function. A Program is usually written in a High-Level language like Assembler, COBOL, PL/I, C, C++, Java etc. Your program statements are then translated into binary machine language, which IBM Mainframes understand. These machine language programs are stored as members in Partitioned datasets. The Partitioned Dataset(PDS), whose members are Machine Language Programs is called Load Module Library, and each such binary program, or member is called Load Module.

To execute a program, you specify which Load Module, and load library in the JCL.
Q. How does MVS Operating System think about Programs?
MVS Operating system doesn’t know about the internals of your COBOL Program. It simply looks at it as a Black-box, which expects some inputs and produces some outputs(without bothering about what’s there inside the box).

Just as you write your own COBOL Programs, to perform some tasks, IBM provides some pre-written ready-made programs, that you can directly lift and use in order to perform some common, basic functionalities. For example, when YOU want to create a copy of a file, you want to sort the contents of a file, there are ready-made programs supplied by IBM, which can do these tasks for you. Such pre-written, ready-to-use programs shipped along with Mainframe computers are called Utility Programs.

One of the ready-made utility programs provided by IBM is IEBGENER. IEBGENER is used to copy the contents of one file to another. It basically creates a shadow copy of a file.

All COBOL programs(whether your own program, or pre-written & ready-made utility) refer to the input and output files that they access, not by the actual(physical) file name, but using a short symbolic name. The short (alias) symbolic name merely refers to the actual file name values. Through JCL, you will be attaching the actual physical file-names to the symbols. 

The IBM Utility – IEBGENER expects 4 files :
Symbolic file name     Description
1. SYSUT1              Where IEBGENER expects to read Input Data
2. SYSUT2              Where IEBGENER expects to write Output Data
3. SYSIN               Where IEBGENER expects to receive any special and optional instructions
4. SYSPRINT            Where IEBGENER expects to write a simple report, about the task it’s done for you, whether it got completed successfully or not, and much more.

Thus, IEBGENER reads input from //SYSUT1 file, and copies it to //SYSUT2 file. It is a simple copy utility.

Image97[1]
Q. What are the different statement types in JCL?
JCL is very simple and easy to master. There are only eight different JCL statement Types. JCL is is actually a piece of cake, because you use only three of these JCL statements most often – JOB, EXEC and DD.

You’ll use these very often!

//name JOB parameters ...
//name EXEC parameters ...
//name DD parameters ...

You’ll use these to “gift-wrap” and pack your JCLs into PROCs

//name PROC parameters ...
//name PEND parameters ...

These are [optional] -
//* comment
/* delimiter
// null ending statement

Now, I shall focus mostly on the 3 important statement types – JOB, EXEC and DD first, so that you can start to write JCL’s and become productive soon. In the later course of this tutorial, I shall also explain to you how to pack JCLs into Procedures using PROC and PEND.

The next figure shows how I use JOB, EXEC and DD Statements to copy a file using IEBGENER Program. Below you shall find a stripped down, bare-bones version of the same.

General format:
//AGY0157A JOB parameters..
//*    
//STEP01 EXEC parameters..
//SYSUT1 DD parameters..
//SYSUT2 DD parameters..
//SYSPRINT DD parameters..
//SYSIN DD parameters..
//    

I hope you recognized this pattern – JOB, EXEC followed by one or more DD Statements. The JCL for all you Batch Jobs will start with one JOB Statement. Following this, the EXEC statement tells which program to run. And, then you code several DD(Data Device) statements, for specifying the input and output files being used by the program. The DD Statement, would assign a symbolic name to an actual dataset name.

Given below is the JCL that executes the IEBGENER Program to copy the contents of the Physical sequential(PS) file AGY0157.INPUT.DATA to AGY0157.OUTPUT.DATA. Click here to download this Job-listing on your box.

Image98[1]

To many people who are thrown to work at a mainframe computer on their first job, they feel lost. Mainframe people seem to speak a completely different language and that doesn't make life easy. What's more, the books and manuals are incredibly hard to comprehend.

"What on earth is a Mainframe?" is an absolute beginner's guide to mainframe computers. We'll introduce you to the hardware and peripherals. We'll talk about the operating system, the software installed on a mainframe. We'll also talk about the different people who work on a mainframe. In a nutshell, we'll de-mystify the mainframe.

Readers based in India, can buy the e-book for Rs. 50 only or the print book. International readers based in the US and other countries can click here to purchase the e-book.