Monday, April 6, 2009

Basic Concepts of Job control language JCL - Tutorial 03

Q. How do we write Output to disk/tape in JCL?
A. Unlike writing output to a dataset, disk/tape are direct Access(DASD) devices. Let us study the JCL that will write the output to the disk.



//JOB1JOB(A123),'STUDENZONE S',
//CLASS=A,PRTY=6
//STEP1EXECPGM=PROGRAM1
//INPUT1DDDSN=INFILE,DISP=SHR
//DISK1DDDSN=DISK.OUTPUT,
//DISP=(NEW,CATLG,DELETE),
//UNIT=DISK,
//SPACE=(TRK,(1,1),RLSE),
//DCB=(RECFM=FB,LRECL=40,BLKSIZE=400)
//TAPE1DDDSN=TAPE.OUTPUT,
//DISP=(NEW,CATLG,DELETE),
//UNIT=TAPE,
//DCB=(RECFM=FB,LRECL=40,BLKSIZE=400)

Let us recollect that all JCL statements basically have 3 broad divisions
//NAME OPERATION OPERANDS

1) All JCL statements begin with two forward slashes //.
2) NAME gives a name to the job, step or ddname.
3) OPERANDS can be positional parameters or keyword parameters.

Let us now see what the DSN(Dataset Name) is written, if you want to write the output of your program(in the JOB) to the Disk. Here the output will be written to a dataset called DISK.OUTPUT.

DISP(Disposition of the Dataset) -
Disposition of the dataset is used to tell the MVS OS, what is the current statusof the data set, what to do with the dataset if the JOB is successful, and what action to take if the JOB is unsuccessful.
DISP(current-status,normal-disposition,abnormal-disposition)

Current-status: The current-status specifies, whether the data-set pre-exists, or it has to be created newly, whether the jobs have exclusive access to it,or multiple jobs can share it.

Normal-disposition : It tells what to do, upon normal execution of the job. The data-set can be saved or deleted.

Abnormal-disposition : It tells what to do, if the JOB terminates with errors(Abnormally Ends - ABENDS). Either the dataset can be saved or deleted.
 DISP(NEW,CATLG,DELETE)
NEW, CATLG and DELETE are positional sub-parameters. They must appear in the same order.

NEW : This tells the MVS OS, the status of the dataset at the start of the JOB. It indicates that the dataset DISK.OUTPUT has to be creatednewly.

CATLG : Upon successful execution of the JOB, the dataset must be added to the System Catalog.

DELETE : Upon unsuccessful execution of the JOB, the dataset must be deleted.

UNIT Parameter :
This is used to identify the physical device on which output data-set is to be placed. During OS(MVS) installation(a process called SYSGEN), the system programmers will have assigned a symbolic name to each physical device.

SPACE
Parameter :

To create the output dataset, we need to first tell the MVS OS. The OS is a memory guagrd. It acts as a watchdog, guarding, protecting the memory. If you want to store the output dataset in computer memory, you must first ask the MVS OS for it. Only when the OS grants your request, then you can go ahead and store data.

The OS is a miser. Even if you want a single byte of memory, you must first ask the MVS OS for it. It does not give any bytes for free.

You must tell the MVS OS, how many bytes of memory space you need to store your data. You do this by writing the SPACE parameter.
SPACE(unit-of-space,(primary,secondary),release)

SPACE(TRK,(1,1),RLSE)

TRK indicates that the space being requested is in Tracks. Since Primary = 1, the MVS OS will initially allocate(reserve) 1 track of disk space, to store the output Dataset. If the size of output dataset exceeds 1 track, (and you run out of space), the MVS OS will allocate 1 additional track of memory space. If your program finds this space also insufficient, it will ABEND.

After successful execution of the job, any space not utilized by the job must be successfully released.

DCB Parameter :
DCB stands for Data Control Block. DCB will tell the MVS OS, the organisation of the dataset. A data-set may have all fixed length records, or the records may be of varying length. You must tell the MVS OS, the length of each record. This should match the record length as specified in the program. Also, a set of records form a block. MVS allocates memory in Blocks. You must specify the Block Size.

Input  -->     COBOL Program-->        Output
Dataset                              Dataset
LRECL=50    INPUT-REC PICTURE X(50)    LRECL=40
           DISK-REC  PICTURE X(40)

DCB=(RECFM=FB,LRECL=40,BLKSIZE=400)

RECFM = FB
It tells the MVS OS, that each record in the output data set, will be of fixed length. If the records are going to be of variable length, we must write RECFM=VB

LRECL=40
It tells the MVS OS, that each record is of length 40 bytes. Since, records are fixed length, all records have the same length = 40 Bytes. If RECFM=VB, then it tells the MVS OS, that the average length of the records is 40 bytes.

BLKSIZE=400
It tells the OS, that on the disk(direct access device), the size of the block will be 400 bytes. Thus, 1 block will at most store 10 records. If RECFM=FB, then BLKSIZE must be multiple of LCRECL. e.g. Block Size 4000 = 10 times x Record Length LRECL (40)