Pages

Wednesday, July 25, 2012

JCL Statements and Procedures

This unit introduces you to JCL jobstreams. You'll look at each principal type of JCL statement to see what functions it performs. Then you'll look at what procedures are and how they are used to streamline job processing in JCL.

After completing this unit, you should be able to:

  • Describe the function and format of basic JCL statements

  • Code basic statements and use them to construct a simple jobstream

  • Explain how procedures are stored and retrieved


Topic 2.1: JCL Statements

*The Basic Statements
Earlier you learned the steps of the payroll program that update a payroll master file.
  • Get a record from a transaction file
  • Get the associated master file record
  • Determine the type of transaction
  • Update the master file appropriately
  • Print a report
We'll focus on the four basic JCL statements: JOB, EXEC, DD and null. There are others, but let's start with the basic building blocks of JCL.

*The JOB Statement
The JCL statements that run the payroll program and identify the required resources are very simple.
First, introduce the job to the system:
//PAYUPD  JOB  (789,ACT-7),HRD,CLASS=1,TIME=30
Examine the following table
Field Description
//PAYUPD Jobname
JOB Type of statement
(789,ACT-7), Accounting information
HRD, Owner
CLASS=1,TIME=30 Priority and run-time

This is the JOB statement. It must always be the first statement in your jobstream.

*Job Numbers
The jobname is only part of the way your job is identified to the system.
When a job is submitted to the system, it is also assigned a number so that it can be further identified. This way, jobs with the same jobname can be uniquely identified.
However, jobs with the same jobname cannot execute simultaneously.
If several jobs with the same name are submitted, they execute sequentially even if the operating system could be processing additional jobs. The operating system will assign a hold status to the jobs waiting to run because of this name conflict.



*Executing a Program
Here's the payroll jobstream so far:
//PAYUPD  JOB  (789,ACT-7),HRD,CLASS=1,TIME=30
Next, select the program to be executed:
//STEP1   EXEC PGM=PAY012

*The EXEC Statement
//STEP1   EXEC PGM=PAY012
Examine the following table
Field Description
//STEP1 Step name
EXEC Type of statement
PGM=PAY012 Program to be executed

This is the EXEC statement. You may have as many as necessary in the jobstream. Each EXEC statement starts a new job step.


*Defining the File
Here is the payroll jobstream so far:
//PAYUPD  JOB  (789,ACT-7),HRD,CLASS=1,TIME=30
//STEP1   EXEC PGM=PAY012                      
Next, define each file accessed. Here is the master file:
//MASTER  DD   DSN=PAY.MASTER,DISP=OLD

*The DD Statement
//MASTER  DD   DSN=PAY.MASTER,DISP=OLD
Examine the following table
Field Description
//MASTER A name defined within the program. This name — the ddname — is the link between the program and the JCL.
DD Type of statement.
DSN=PAY.MASTER, Name of data set. This name — the dsname — is the name given to the data set when it is created on tape or disk.
DISP=OLD This data set exists and is cataloged. A catalog is a list of data sets maintained by the system that contains their location and attributes.

This is the DD (Data Definition) statement. One must be present for each file the program accesses. They may be coded in any order.



    //PAYUPD  JOB  (789,ACT-7),HRD,CLASS=1,TIME=30
    //STEP1   EXEC PGM=PAY012
    //MASTER  DD   DSN=PAY.PAY001,DISP=OLD          
    //TRANS   DD   DSN=PAY.TRANS,DISP=OLD           
    //REPORT  DD   SYSOUT=A                         

*More DD Statements
The complete jobstream must contain a DD statement for each data set accessed. The one for the payroll program might look like this.

    //PAYUPD  JOB  (789,ACT-7),HRD,CLASS=1,TIME=30
    //STEP1   EXEC PGM=PAY012
    //MASTER  DD   DSN=PAY.PAY001,DISP=OLD          
    //TRANS   DD   DSN=PAY.TRANS,DISP=OLD           
    //REPORT  DD   SYSOUT=A                         
   
*The Null Statement
Lastly, end the jobstream with the null statement. If you do not code this statement, the system supplies it for you.

*Delimiters
Many times you will see this statement in a jobstream in positions 1 and 2:
/*
It is called a delimiter.
The delimiter marks the end of any data placed directly into the jobstream. This type of data is called instream data. The /* tells the system that the incoming data is complete. You'll see more about instream data later.

Topic 2.2: JCL Procedures

*Reusing JCL Statements
You have seen what the principal types of JCL statements are and how they are put together to run a job. Often you want to use the same JCL statements in many jobs. The JCL option available to accommodate this is a procedure.
This section briefly discusses this topic. A later course in the JCL series provides more depth.
Let's look now at what procedures are and how they are used to streamline job processing in JCL.

*Subroutines
When a part of a program's code performs some specific function, that part of the program is known as a subroutine. Programs may also call other programs that perform general or frequently used subroutines.
JCL uses procedures to accomplish much the same purpose. JCL procedures provide a way to store and retrieve frequently used sets of JCL statements.
Your System group provides procedures for you to use to access systems like SAS, FOCUS, ORACLE, or compilers like COBOL, or your own in-house systems.



*Storing Procedures
A JCL procedure is a series of JCL statements that are stored in a procedure library and given a unique name. A procedure library contains JCL procedures that are stored and accessed by name. A procedure library is often referred to as a PROC LIB.
Let's look at how procedures are stored.

                                                  
                                                  +——————————————————+
    //STEP1   EXEC PGM=PAY001               |     +——————————————————+
    //TRANS   DD   DSN=PAY.TRANS,DISP=OLD   |<——> |        |
    //MASTER  DD   DSN=PAY.MASTER,DISP=OLD  |     +——————————————————+
    //PRINT   DD   SYSOUT=A                 |     |                  |
                                                  +——————————————————+
*The Procedure Library
JCL statements to perform a task are written and stored in a procedure library. The procedure, consisting of the JCL statements, becomes a member of the procedure library. The name of the member in the example is PAY. The JCL code shown is the contents of this member.



*Retrieving Stored Procedures
After procedures are stored, you can retrieve them by name.
Procedures are invoked using the EXEC statement. The EXEC statement causes a series of JCL statements (a library member) to be retrieved from the library. In effect, the JCL statements replace the EXEC statement. The procedure is brought into the jobstream (instream) with the rest of the job's JCL statements.
Let's look at how this is done.

     //PAYJOB  JOB
     //PAY01   EXEC PROC=PAY

*Executing a Procedure
To invoke the procedure, you code an EXEC statement requesting the procedure by name, as in the example.
Notice the EXEC statement is requesting a PROC (procedure) rather than a PGM (program).

     //PAYJOB  JOB
    

*With or Without PROC
A procedure may also be requested without coding the PROC=. The system defaults to a procedure when PGM= and PROC= are not coded.
//PAY01  EXEC PAY is identical to the EXEC statement above.

    //PAYJOB  JOB                                 
    //PAY01   EXEC PROC=PAY                       +——————————————————+
                   |     +——————————————————+
       |<——— |        |
      |     +——————————————————+
                     |     |                  |
                                                  +——————————————————+
*How It Works
The operating system looks in the procedure library for the requested member and places all its statements instream.
The four statements of the procedure are brought in and listed just as if they were coded there. They are placed immediately after the EXEC statement that calls them.


*Using Procedures
There are many considerations about procedures. Some that you'll encounter later in this course show you
  • How to append statements to a procedure during your job's execution. For example in a procedure that copies files, the DD statement for the file to be copied is omitted. You append one when you use the procedure.

  • How to substitute a value for a symbolic parameter. These parameters are coded in procedures as symbols that can be assigned different values each time the procedure is run. For example a procedure that copies files might use a symbolic parameter for the name of the data set to be copied.


*For More Information
Other considerations are beyond the scope of this course, e.g. how to modify the statements for your job only, or how to search though several PROC libraries to find the procedure.
If you find that you need this information, consult your IBM manual.

*The INCLUDE Group
Another way to handle a series of JCL statements is called an INCLUDE group.
INCLUDE groups give you more flexibility in coding JCL statements. They allow you to place a group of statements into your JCL code without cataloging them in a procedure library or coding them directly into the jobstream.
Refer to your IBM manual for more information on INCLUDE groups.

Topic 2.3: Unit 2 Summary

In this unit you learned the following:
  • The JOB statement is the first JCL statement in a jobstream. It defines the job to the system.

  • The EXEC statement is the first JCL statement in a job step. It defines the program to be executed. Any number of EXEC statements can occur in a jobstream.

  • The Data Definition (DD) statement defines the data set to be used in the program.

  • The null statement is the last statement in the JCL jobstream. This statement consists of slashes (//) in the first two positions.

  • The delimiter statement /* marks the end of instream data in the jobstream.

  • JCL procedures provide a way to store and retrieve frequently used sets of JCL statements.

  • The system stores procedures in a procedure library. Each procedure is a member of the library.

  • You invoke a JCL procedure by name using the EXEC statement. The system retrieves a series of JCL statements (a library member) from the library.

  • If you omit the PGM= and PROC= parameters from an EXEC statement, the system assumes that a PROC is to be executed.

1 comment: