Sunday, November 11, 2012

MVS JCL Reviewer Part 1

JCL (Job Control Language)

Three basic statements in a JCL.
  • 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.     
 
How does override work on a JCL?

Without changing the actual procedure, we can add/modify contents of procedure. 
There are two types of modifications:
on EXEC statement
on DD statement 

  • On EXEC statement, we can do following functions on EXEC statement in a procedure:     

         Adding parameter to an EXEC statement / all EXEC statement
   PROCEDURE STATEMENT
    //STEP10 EXEC PGM=COBPROG,TIME=3

    PARAMETER ADDING 

   //MYSTEP EXEC PROC=MYPROC,REGION.STEP10=56K 
   (for single step)
   REGION will be added to the STEP10 in MYPROC procedure

   PARAMETER ADDING
   //MYSTEP EXEC PROC=MYPROC,REGION=56K
   (for single step)  
   If REGION is not available for any step in that procedure,  
   REGION will be added to all steps in procedure.  
   If REGION is available for any step in procedure, REGION value will be overriden.

   Modify parameter on EXEC statements                                 
   PROCEDURE STATEMENT:  
   //STEP10 EXEC PGM=COBPROG,TIME=30   

   PARAMETER OVERRIDE: 

   //MYSTEP EXEC PROC=MYPROC,TIME.STEP1 
   Now Resulting TIME value for that step (in proc) is 40

   Nullifying the parameter value   
   PROCEDURE STATEMENT:  
   //STEP10 EXEC PGM=COBPROG,TIME=30

   PARAMETER ADDING:  
   //MYSTEP EXEC PROC=MYPROC,TIME.STEP10=  
   Don’t give any value for that parameter, this will nullify the parameter value in procedure.
 
  •  On DD statement:   
     
    Syntax for add/modify DD statements in a procedure  
    //name                   EXEC   [PROC=]procedure-name  
    //[procstepname].ddname  DD     parameter=value  
    //     
     
    We can do following functions on EXEC statement in a procedure using above syntax. 
    Modify existing parameter on DD statements within a procedure 
    Add parameter to existing DD statement within a procedure 
    Add DD statement to a job step 
    Nullify the effect of parameter on DD statement in a procedure.     

What is the difference between Sequential Dataset and Partitioned Dataset? 

• Any named collection of data is called a data set. A partitioned dataset consists of multiple files within one data structure. A sequential dataset consists of one file within a data structure.
• A partitioned dataset differs from a sequential dataset in that it has a directory of its members.
Whenever you refer to a member of a partitioned dataset, you include the member name in parentheses.

  • Partitioned Dataset 
1. individual members are read/manipulated without disturbing other members
2. it is advisable to never write directly to a partitioned dataset in your program
3. on DD statememt: DSN=userid.file(member)
4. call from editor: file(member)

PARTITIONED DATASET DSN='userid.data-set-name(member)'
  ______________
|    DIRECTORY   |
|-------------------|
|      MEMBER1    |
|-------------------|
|      MEMBER2    |
|-------------------|
|      -----------      |
|-------------------|
|      MEMBERn    |
|-------------------|
|______________|

  • Sequential Dataset 
1. dataset must be read from top to bottom
2. on DD statement: DSN=userid.file
3. call from editor: file

SEQUENTIAL DATASET DSN='userid.data-set-name'


______________
|                          |
|                          |
|                          |
|     DATASET     |
|                          |
|                          |
|                          |
|_____________|


What are the parameters needed to define a Data Set?

  • The Data Sets used by a job step requires a Data Definition (or DD) statement. 
  • A simple DD statement requires the following:
o    DDNAME
o    Data Set Name (or DSN)
o    Disposition (or DISP) keyword.

Example:
//DDNAME DD DSN=dsname,DISP=(status,normal-term,abnormal-term)   

In the preceding example the DDNAME in the JCL DD statement corresponds to the name used in the COBOL SELECT statement. The DSN= keyword specifies the fully-qualified MVS Data Set Name. 
The DISP= keyword and parameter specifies the disposition as follows.

status
Description
OLD
The dataset exists and this job step has exclusive use of the dataset.
SHR
The dataset exists and other users and jobs can access the dataset, this is the default
MOD
The dataset should be kept and new records will be appended to the end of the dataset. The dataset may or may not exist. If it does not exist then a data set will be created.
NEW
The dataset does not exist and will be created.
normal-term
Description
DELETE
Deletes the data set at the end of the step
KEEP
Keeps the data set.
CATLG
Places the entry in the system catalog or user catalog. For a NEW data set this is the default.
UNCATLG
Deletes the entry from the system catalog or user catalog.
abnormal-term 
Description
DELETE
Indicates that the data set is to be deleted at the end of a job step.
KEEP
Indicates that the data set is to be kept.
CATLG
Indicates that the system should place an entry in the system or user catalog.
UNCATLG
Indicates that the system is to delete the entry in the system or user catalog.

          The DD statement for an Existing Data Sets:
o    The DD name should be in positions 3-n (for a maximum of 8 characters) followed by a space.
o    The DDNAME should correspond to the name defined in the program. For example, with COBOL the name defined by the ASSIGN clause of the SELECT statement. 
      
      The following is an example of a DD statement followed by a COBOL SELECT 
      statement with an ASSIGN clause. 
      //FILEIP DD  DSN=MY.EXISTING.DATASET,DISP=SHR

      The following is an example of a COBOL SELECT with an ASSIGN clause.
      SELECT INPUT-FILE ASSIGN to FILEIP  

The DD statement for an Existing Data Sets:
o Other than the DD Name, DSN and DISP, new datasets also require the UNIT, VOL, SPACE and DCB parameters. 
//FILEOP DD DSN=MY.NEW.DATASET,DISP=(NEW,CATLG,DELETE), 
// UNIT=SYSDA, 
// VOL=SER=TST001, 
// SPACE=(CYL,30,4), 
// DCB=(RECFM=FB,LRECL=512,BLKSIZE=5120) 

o UNIT Parameter: 
In IBM Mainframe environment, all devices have an address assigned to them at the time
they added to the system. Devices can be referenced using these addresses. UNIT
parameter is used to specify this address. 
      

In above example, FILEOP may reside on any of the devices which are grouped under the 
symbolic name SYSDA will be accessed. 

o VOL Parameter: 
This parameter is used to identify the volume serial number on which dataset resides. 
The VOL dataset is used with disk and tape datasets. 

Sub parameters used with VOL parameter: 
1. SER - Specification of serial number 
2. REF - Referencing VOL specification from a prior step 
3. PRIVATE - Allowing access to volume by single user 
4. RETAIN - Inhibiting dismounting of volume until end of job 
5. SEQ - Specification of sequence in which volumes are to be mounted 

o SPACE Parameter: 
The SPACE parameter is used to allocate space for datasets. 
All new data sets on disk volumes must be allocated space. 
Storage on disk volumes can be allocated in units of Cylinders (CYL), Tracks (TRK), Blocks (BLK) and Bytes. 

Syntax: 
SPACE=(CYL,(primary,secondary,directory),RLSE,CONTIG,MXIG,ROUND) Note: Instead of CYL, We can use TRK or BLK 

The primary amount can be conservative, with the secondary amount providing a reserve.
The secondary amount provides for data set growth over time. 

Meaning of Sub Parameter 
1. PRIMARY - Primary storage to be allocated at the time of data set created 
2. SECONDARY - Additional storage to be allocated, if primary storage is not sufficient. Up to 15 times only. 
3. DIRECTORY - Space for recording of name and location of partitioned data sets 
4. RLSE - Request for release of space previously allocated unused space after completion of job 
5. CONTIG - Request for contiguous space 
6. MXIG - Request for large area of contiguous space 
7. ROUND - Request for entire cylinder for storage of data set 

In this example, 30 cylinders are requested as primary space and 4 additional cylinders as secondary space. 
Up to 15 extents of secondary space can be allocated. 

To compute total space, formula is: 
Total Space = (1 * primary) + (15 * secondary) 

o DCB Parameter: 

The Data Control Block (DCB) parameter is used to specify - 
record format (RECFM), record length (LRECL) and block size (BLKSIZE)

Record Format (RECFM) can be: 
1. Fixed (F) 
2. Fixed-Block (FB) 
3. Variable (V) 
4. Variable-Block (VB) 
5. Undefined length (U) 

Record Length (LRECL) specifies the length of the record. 
LRECL can range from 1 to 32760 bytes. 

When you specified V for RECFM parameter, LRECL value is largest record in the file plus
4 bytes. These four bytes contain the actual length of each variable length record in the file 

Depending on the record format, record length varies as follows: 
1. Equal to the record length for fixed-length records 
2. Equal to the size of the largest record plus the 4 bytes describing the record's size for variable-length records 
3. Omit the LRECL for undefined records. 

Block Size (BLKSIZE) specifies the block size if you wish to block records. 
It must follow the following rules: 
1. must be a multiple of LRECL for fixed-length records 
2. must be equal to or greater than LRECL for variable-length records 
3. must be as large as the longest block for undefined-length records 
4. BLKSIZE can range from 1 to 32760 bytes 

Use BLOCK CONTAINS 0 RECORDS in your FD (and BLKSIZE=0 in your JCL DCB 
parameters) to allow the OS/390 operating system to optimize your block size. These two 
changes ensure that the maximum number of records will be processed for a single file 
input/output operation. 

For an output dataset, if BLOCKSIZE is omitted from the FD section of the program or if 
BLOCK CONTAINS 0 is specified, it will get the BLOCKSIZE defined in the DD 
parameters (i.e. DCB) or dataset label of the file from the JCL.. 

It’s always better to write BLOCK CONTAINS 0 RECORDS / CHARACTERS in 
COBOL program so that you can specify the BLKSIZE in JCL. Suppose there is a 
requirement to change the BLKSIZE due to change in LRECL this will cause only change in 
BLKSIZE in JCL. If you mention BLOCK contains N records in COBOL program, then it 
is required to match with BLKSIZE in JCL also it would be required to change COBOL + 
JCL both. 

If you code BLKSIZE=0 in your DCB, the system will determine the most efficient block 
size for space utilization. 

MVS JCL Reviewer Part 2 can be viewed here.

No comments:

Post a Comment