Pages

Thursday, July 26, 2012

JCL: Coding and Executing Procedures

Unit 1. Execution

In this course, you will learn how procedures are executed as part of the jobstream, and how to code procedures that are both flexible and reusable. You will also learn how to use symbolic parameters in your JCL code.
In this unit, you will learn how procedures are coded in with other JCL, and how each type of JCL statement is displayed in the job output.

After completing this unit, you should be able to:

  • Explain how procedures are merged with other JCL during execution

  • Identify in the job output which statements were coded instream, from an instream procedure, or from a cataloged procedure


Topic 1.1: Procedures in the Jobstream

 

*Executing Procedures

When you execute a procedure — whether instream or cataloged — it is merged with the other JCL in your job.
It's as though the entire procedure were coded right there at the EXEC statement.  

//CMPL    JOB  (9797,DEPTK),G.SAMSA
    //S1   EXEC COMPILE
*What Is Coded
Here is the JCL as it is coded instream.

    //CMPL    JOB  (9797,DEPTK),G.SAMSA
    //S1   EXEC COMPILE

*What Is Executed
Here is the JCL that is actually executed after the procedure is called in.
Remember:
  • The SYSIN DD statement is no longer part of the procedure.
  • The seven SYSUT DD statements display in this abbreviated format.


    //CMPL    JOB  (9797,DEPTK),G.SAMSA
    //S1   EXEC COMPILE
  
*Completing the Jobstream
To complete the jobstream, the SYSIN DD statement for the COBOL source program must be added.

    //CMPL    JOB  (9797,DEPTK),G.SAMSA
    //S1   EXEC COMPILE

    //SYSIN  DD  DSN=MYPROG,DISP=(OLD,KEEP)
*The Expanded Procedure
You can see how the procedure is actually expanded in line with your other JCL statements.


*Instream Procedure
If COMPILE is an instream procedure, here is what your jobstream looks like.
    //CMPL    JOB  (9797,DEPTK),G.SAMSA
    //COMPILE PROC
    //STEP1  EXEC  PGM=IGYCRCTL
    //SYSUT1   DD  UNIT=SYSDA,SPACE=(CYL,(1,1))
        :
    //SYSUT7   DD  UNIT=SYSDA,SPACE=(CYL,(1,1))
    //SYSPRINT DD  SYSOUT=A
    //SYSLIN   DD  DSN=MYOBJECT,UNIT=SYSDA,SPACE=(CYL,1),DISP=(NEW,KEEP)
    // PEND
    //S1   EXEC COMPILE
    //SYSIN  DD  DSN=MYPROG,DISP=(OLD,KEEP)

*Expanded Procedure
And here is how the procedure is expanded.
    //CMPL    JOB  (9797,DEPTK),G.SAMSA
    //COMPILE PROC
    //STEP1  EXEC  PGM=IGYCRCTL
    //SYSUT1   DD  UNIT=SYSDA,SPACE=(CYL,(1,1))
        :
    //SYSUT7   DD  UNIT=SYSDA,SPACE=(CYL,(1,1))
    //SYSPRINT DD  SYSOUT=A
    //SYSLIN   DD  DSN=MYOBJECT,UNIT=SYSDA,SPACE=(CYL,1),DISP=(NEW,KEEP)
    // PEND
    //S1   EXEC COMPILE

    //SYSIN  DD  DSN=MYPROG,DISP=(OLD,KEEP)

    //CMPL    JOB  (9797,DEPTK),G.SAMSA
    //S1   EXEC COMPILE
    
*Appending Other Statements
Other JCL statements besides the SYSIN statement may be appended to the procedure after the EXEC statement.
For example, the COBOL compiler often requires the SYSLIB DD statement if you are copying in information like file definitions.


Topic 1.2: Procedures in Output

*Looking at Output
When you look at the output from the job run, the system provides an easy way to identify which statements were:
  • Coded instream
  • From an instream procedure
  • From a cataloged procedure 

*Identifying Statements
The coding scheme that the system uses to identify each type of JCL statement works like this:
Instream JCL statements are displayed preceded by //.
Expanded instream procedure statements are displayed preceded by ++.
Expanded cataloged procedure statements are displayed preceded by XX.

*Summarizing the Scheme
The coding scheme that the system uses to identify each type of JCL statement works like this:

Examine the following table
JCL Statement Displayed preceded by
Instream //
Instream procedure ++
Cataloged procedure XX

The chart above summarizes the coding scheme.


 //CMPL    JOB  (9797,DEPTK),G.SAMSA,MSGLEVEL=1
    //S1   EXEC COMPILE
    //SYSIN  DD  DSN=MYPROG,DISP=(OLD,KEEP)
*A Cataloged Procedure
Here is your jobstream executing a cataloged procedure.
Let's see how the output of this job displays.

    //CMPL    JOB  (9797,DEPTK),G.SAMSA,MSGLEVEL=1
    //S1   EXEC COMPILE

    //SYSIN  DD  DSN=MYPROG,DISP=(OLD,KEEP)
*Cataloged Procedure Output
Here is the output. The cataloged procedure statements are identified by XX.

    //CMPL    JOB  (9797,DEPTK),G.SAMSA,MSGLEVEL=1
    //COMPILE PROC
    //STEP1  EXEC  PGM=IGYCRCTL
    //SYSUT1   DD  UNIT=SYSDA,SPACE=(CYL,(1,1))
        :
    //SYSUT7   DD  UNIT=SYSDA,SPACE=(CYL,(1,1))
    //SYSPRINT DD  SYSOUT=A
    //SYSLIN   DD  DSN=MYOBJECT,UNIT=SYSDA,SPACE=(CYL,1),DISP=(NEW,KEEP)
    // PEND
    //S1   EXEC COMPILE
    //SYSIN  DD  DSN=MYPROG,DISP=(OLD,KEEP)
*An Instream Procedure
Here is your jobstream executing an instream procedure. See how its output displays.

    //CMPL    JOB  (9797,DEPTK),G.SAMSA,MSGLEVEL=1
    //COMPILE PROC
    //STEP1  EXEC  PGM=IGYCRCTL
    //SYSUT1   DD  UNIT=SYSDA,SPACE=(CYL,(1,1))
        :
    //SYSUT7   DD  UNIT=SYSDA,SPACE=(CYL,(1,1))
    //SYSPRINT DD  SYSOUT=A
    //SYSLIN   DD  DSN=MYOBJECT,UNIT=SYSDA,SPACE=(CYL,1),DISP=(NEW,KEEP)
    // PEND
    //S1   EXEC COMPILE

    //SYSIN  DD  DSN=MYPROG,DISP=(OLD,KEEP)
*Instream Procedure Output
Here is the output displayed. Notice the expanded instream procedure statements are preceded by ++.


Topic 1.3: Unit 1 Summary

In this unit, you learned the following:
  • When you execute a procedure — whether instream or cataloged — it is merged with the other JCL in your job.

  • When you look at the output from the job run, the system provides an easy way to identify which statements were coded instream, from an instream procedure, or from a cataloged procedure.


Unit 2. Multi-Step Jobs

In this unit, you will see how procedures are executed along with other job steps. Since a typical multi-step job might involve compile and binder steps, the requirements of the binder program IEWBLINK are discussed.
The discussion starts with definitions of the JOB and PROC steps. Then your procedure COMPILE is expanded and reviewed for possible problems.

After completing this unit, you should be able to:

  • Explain JOB steps and PROC steps in a jobstream

  • Identify problems in a sample multi-step job


Topic 2.1: JOB and PROC Steps


    //COMPILE PROC
    //STEP1  EXEC  PGM=IGYCRCTL
    //SYSUT1   DD  UNIT=SYSDA,SPACE=(CYL,(1,1))
        :
    //SYSUT7   DD  UNIT=SYSDA,SPACE=(CYL,(1,1))
    //SYSPRINT DD  SYSOUT=A
    //SYSLIN   DD  DSN=MYOBJECT,UNIT=SYSDA,SPACE=(CYL,1),DISP=(NEW,KEEP)
*The COMPILE Procedure
Here is the procedure COMPILE again. Assume that you placed it in a procedure library.
As you proceed, you'll see that the decision to use a library involves more than just knowing which library and member name to use!

    //CMPL    JOB  (9797,DEPTK),G.SAMSA,MSGLEVEL=1
    //S1   EXEC COMPILE
    //SYSIN  DD  DSN=MYPROG,DISP=(OLD,KEEP)
*Executing the Procedure
The jobstream above executes the procedure COMPILE.

    //CMPL    JOB  (9797,DEPTK),G.SAMSA,MSGLEVEL=1
    //S1   EXEC COMPILE

    //SYSIN  DD  DSN=MYPROG,DISP=(OLD,KEEP)
*The Expanded Procedure
This is what you see on your JCL listing when the PROC is executed. Notice how the procedure is brought in and expanded instream.
Remember, XX precedes expanded cataloged procedures.

    //CMPL    JOB  (9797,DEPTK),G.SAMSA,MSGLEVEL=1
    XXSTEP1  EXEC  PGM=IGYCRCTL
    XXSYSUT1   DD  UNIT=SYSDA,SPACE=(CYL,(1,1))
      :
    XXSYSUT7   DD  UNIT=SYSDA,SPACE=(CYL,(1,1))
    XXSYSPRINT DD  SYSOUT=A
    XXSYSLIN   DD  DSN=MYOBJECT,UNIT=SYSDA,SPACE=(CYL,1),DISP=(NEW,KEEP)
    //SYSIN  DD  DSN=MYPROG,DISP=(OLD,KEEP)
JOB Steps
Now, let's define a JOB step.
Each EXEC statement explicitly coded in your instream JCL defines a JOB step. The JOB step may execute a program or a procedure.

   //CMPL    JOB  (9797,DEPTK),G.SAMSA,MSGLEVEL=1
    //S1   EXEC COMPILE
   
    XXSYSUT1   DD  UNIT=SYSDA,SPACE=(CYL,(1,1))
      :
    XXSYSUT7   DD  UNIT=SYSDA,SPACE=(CYL,(1,1))
    XXSYSPRINT DD  SYSOUT=A
    XXSYSLIN   DD  DSN=MYOBJECT,UNIT=SYSDA,SPACE=(CYL,1),DISP=(NEW,KEEP)
    //SYSIN  DD  DSN=MYPROG,DISP=(OLD,KEEP)
PROC Steps
Next, let's define a PROC step.
Each EXEC statement within a procedure defines a PROC step. The name on the EXEC statement within the PROC is called the procedure step name. 

*Distinguishing JOB Steps and PROC Steps
It is important to be able to distinguish PROC steps and JOB steps as your jobstreams become more complex.
You may need to alter the statements contained within a procedure at execution time. (Yes, this can be done and will be covered shortly.)
And to do this, you must be able to explicitly state which JOB or PROC step is to be altered.
First, let's look at a more complex procedure.

    //UPDATE  PROC
    //BKUP  EXEC  PGM=CPY
    //DDIN    DD  DSN=MASTER,DISP=OLD
    //DDOUT   DD  DSN=SAV.MASTER,DISP=(,PASS),UNIT=SYSDA,SPACE=(CYL,(1,1))
    //SYSOUT  DD  SYSOUT=A
    //UPDT  EXEC  PGM=UPDT
    //MAST    DD  DSN=MASTER,DISP=OLD
    //TRANS   DD  DSN=TRANS,DISP=OLD
    //SYSOUT  DD  SYSOUT=A
    //RSTR  EXEC  PGM=CPY,COND=(0,NE,UPDT)
    //DDIN    DD  DSN=SAV.MASTER,DISP=OLD
    //DDOUT   DD  DSN=MASTER,DISP=OLD
    //    PEND
*A Multi-Step Procedure
Above is a procedure that contains multiple steps.
Each PROC step consists of an EXEC statement and its associated DD statements.
One procedure step ends where the next one begins.





    //ALSUPD JOB  (9797,DEPTK),G.SAMSA,MSGLEVEL=1
    //BKUP  EXEC  PGM=CPY
    //DDIN    DD  DSN=MASTER,DISP=OLD
    //DDOUT   DD  DSN=SAV.MASTER,DISP=(,PASS),UNIT=SYSDA,SPACE=(CYL,(1,1))
    //SYSOUT  DD  SYSOUT=A
    //UPDT  EXEC  UPDATE
    //RSTR  EXEC  PGM=CPY,COND=(0,NE,UPDT)
    //DDIN    DD  DSN=SAV.MASTER,DISP=OLD
    //DDOUT   DD  DSN=MASTER,DISP=OLD
*A Multi-Step Job
Above is a jobstream that executes both instream JCL and procedures.
A JOB step consists of the EXEC statement and its associated DD statements — the same as a PROC step.


*Step Names...
The names on the PROC steps and JOB steps are checked for validity only. The system doesn't check to see if they make sense or if they are repeated.
The names must follow these guidelines:

  • No longer than eight alphanumeric or national characters
  • Start with an alphabetic or national character


*Can Omit or Repeat
The PROC step name or JOB step name may be:
  • Omitted
  • Repeated in different steps


*Naming Your Steps Carefully
Although the rules for step names are rather liberal, you should enforce more stringent standards on yourself when coding them.
It is to your advantage to label each step with a unique and meaningful name so that you can identify the step easily.


Topic 2.2: Sample Multi-Step Job

*Adding to the COMPILE Procedure
Any number of JOB steps and PROC steps can be combined to make up a job.
Now, let's define a multi-step job using the procedure COMPILE that you stored previously. Let's have it compile your COBOL program and then bind and store it in a program library.
Note: The DFSMS/MVS program management binder replaces the MVS/DFP linkage editor in preparing a program for execution.
Let's expand the COMPILE jobstream to include the bind step. Then see how the job looks and what happens.

    //CMPL    JOB  (9797,DEPTK),G.SAMSA,MSGLEVEL=1
   
    //SYSIN  DD  DSN=MYPROG,DISP=(OLD,KEEP)
    //S2  EXEC  PGM=IEWBLINK
    //SYSLIN  DD  DSN=MYOBJECT,DISP=OLD
    //SYSLMOD  DD  DSN=MYLIB(PROG1),DISP=SHR
    //SYSLIB  DD  DSN=SYS1.COBLIB,DISP=SHR
*Invoking the Procedure
In this example S1 invokes the procedure COMPILE which compiles your COBOL program and puts the object module in MYOBJECT.



    //CMPL    JOB  (9797,DEPTK),G.SAMSA,MSGLEVEL=1
    //S1  EXEC  COMPILE
    //SYSIN  DD  DSN=MYPROG,DISP=(OLD,KEEP)
   
    //SYSLIN  DD  DSN=MYOBJECT,DISP=OLD
    //SYSLMOD  DD  DSN=MYLIB(PROG1),DISP=SHR
    //SYSLIB  DD  DSN=SYS1.COBLIB,DISP=SHR
*Step S2
Step S2 executes the binder IEWBLINK which is supposed to:

  • Take the object module MYOBJECT (found on the SYSLIN DD statement),
  • Attach any COBOL routines used by the program from SYS1.COBLIB (found on the SYSLIB DD statement), and
  • Bind the entire module into program library MYLIB, in member PROG1 (found on the SYSLMOD DD statement).


*The Binder's Requirements
This chart summarizes what the binder IEWBLINK requires.
Examine the following table
Data Set DD Name
Object module MYOBJECT SYSLIN
Subroutine library SYS1.COBLIB SYSLIB
Program library MYLIB(PROG1) SYSLMOD

Now, let's examine this jobstream and see if it works as planned.

DDs or No DDs?
So — to execute COMPILE with your COBOL program in a data set, the JOB step needs to contain a SYSIN DD statement. The procedure supplies all the other DDs.
But to execute the program IEWBLINK, all the DD statements must be specified as part of the JOB step.
To make this a little clearer, look on the next page at how the job appears on the listing with the procedure expanded instream. 
    //CMPL    JOB  (9797,DEPTK),G.SAMSA,MSGLEVEL=1
    //S1  EXEC  COMPILE
    XXSTEP1  EXEC  PGM=IGYCRCTL
    XXSYSUT1   DD  UNIT=SYSDA,SPACE=(CYL,(1,1))
        :
    XXSYSUT7   DD  UNIT=SYSDA,SPACE=(CYL,(1,1))
    XXSYSPRINT DD  SYSOUT=A
   
    //SYSIN  DD  DSN=MYPROG,DISP=(OLD,KEEP)
    //S2  EXEC  PGM=IEWBLINK
   
    //SYSLMOD  DD  DSN=MYLIB(PROG1),DISP=SHR
    //SYSLIB  DD  DSN=SYS1.COBLIB,DISP=SHR
*No Data Set Location
The procedure's SYSLIN statement specified a DISP of NEW,KEEP. Therefore, the next step has no idea where the data set was placed.

    //CMPL    JOB  (9797,DEPTK),G.SAMSA,MSGLEVEL=1
    //S1  EXEC  COMPILE
    XXSTEP1  EXEC  PGM=IGYCRCTL
    XXSYSUT1   DD  UNIT=SYSDA,SPACE=(CYL,(1,1))
        :
    XXSYSUT7   DD  UNIT=SYSDA,SPACE=(CYL,(1,1))
    XXSYSPRINT DD  SYSOUT=A
    XXSYSLIN   DD  DSN=MYOBJECT,UNIT=SYSDA,SPACE=(CYL,1),
    //SYSIN  DD  DSN=MYPROG,DISP=(OLD,KEEP)              
    //S2  EXEC  PGM=IEWBLINK
    //SYSLIN  DD  DSN=MYOBJECT,DISP=OLD
    //SYSLMOD  DD  DSN=MYLIB(PROG1),DISP=SHR
    //SYSLIB  DD  DSN=SYS1.COBLIB,DISP=SHR
*Staying Flexible
For the JCL to execute properly, a DISP of NEW,PASS should be specified. Or, you can choose a specific volume and refer to it at each step.
However, a data set disposition of NEW,PASS is the most flexible, so that is what you will see here.

*What Else Can Happen?
So, as you can see, the COMPILE procedure already has one problem.
And what if you had two or three programs to compile? Let's see what else will happen with the procedure as coded.

COMPILE Needs Some Work
So, the procedure COMPILE is not without problems!
It was great for one particular circumstance, but doesn't lend itself to other necessary uses.
When placed in complex multi-step jobs, the parameters in its DD statements are not flexible enough.

*Reviewing the Problems
To recap:
One problem came up when you tried to combine the COMPILE procedure with the binder step:
1. The SYSLIN statement did not pass the data set's attributes to the next step.
Additional problems were found trying to execute the COMPILE procedure more than once:
2. A different data set is needed for each object module.
3. The DISP parameter on the SYSLIN DD statement will cause a new data set to be created each time.
If the COMPILE procedure is executed more than once in a job, chances are that you will get this message: DUPLICATE DATA SET ON VOLUME.

*Solving the Problems
There are three different techniques that you can employ to solve these problems:
1. Postpone defining the SYSLIN statement until execution.
2. Define the SYSLIN statement with symbolic parameters for some of its attributes and substitute the desired values at execution time.
3. Override the SYSLIN statement at execution with the necessary parameters.


Topic 2.3: Unit 2 Summary

In this unit, you learned the following:
  • Each EXEC statement explicitly coded in your instream JCL defines a JOB step.

  • Each EXEC statement within a procedure defines a PROC step.

  • The names on the PROC steps and JOB steps are checked for validity only.

  • Any number of JOB steps and PROC steps can be combined to make up a job.


Unit 3. Postponing the DD until Execution

In this unit, you'll see how coding the DDNAME parameter in a procedure allows you to postpone coding a complete DD statement until execution.
This is one way to solve the problem encountered in the previous unit: When the procedure COMPILE was placed in a job with other steps, the parameters on its SYSLIN DD weren't flexible enough to accommodate requests.

After completing this unit, you should be able to:

  • Code the DDNAME parameter in a JCL procedure

  • Identify situations when the DDNAME parameter should be used


Topic 3.1: The DDNAME Parameter

*The Parameter Format
The DDNAME parameter is an optional keyword parameter of the DD statement. With it, you may put off defining the entire data set attributes until the job step executes.
The format of the parameter is:
//DDIN1   DD  DDNAME=ddname
//DDIN1           This is the DDname expected by the program.
DDNAME=ddname This is the DDname of a new DD statement. It will
                       define the data set.

*How It Works
Here is the COMPILE procedure with an example of a jobstream that executes COMPILE.
OBJECT is specified as the DDNAME parameter on the SYSLIN DD statement. Thus, you can wait until the procedure executes to define the SYSLIN data set.
Procedure
 //COMPILE PROC                             
 //STEP1  EXEC  PGM=IGYCRCTL                
 //SYSUT1   DD  UNIT=SYSDA,SPACE=(CYL,(1,1))
 //SYSUT2   DD  UNIT=SYSDA,SPACE=(CYL,(1,1))
     :                                      
 //SYSUT7   DD  UNIT=SYSDA,SPACE=(CYL,(1,1))
 //SYSPRINT DD  SYSOUT=A

Procedure
 //COMPILE PROC                             
 //STEP1  EXEC  PGM=IGYCRCTL                
 //SYSUT1   DD  UNIT=SYSDA,SPACE=(CYL,(1,1))
 //SYSUT2   DD  UNIT=SYSDA,SPACE=(CYL,(1,1))
     :                                      
 //SYSUT7   DD  UNIT=SYSDA,SPACE=(CYL,(1,1))
 //SYSPRINT DD  SYSOUT=A



*Examining the Procedure
On the left are the procedure's statements — on the right are those from the jobstream with the binder step.
Procedure                                      Jobstream
 //COMPILE PROC                                //S1  EXEC  COMPILE
 //STEP1  EXEC  PGM=IGYCRCTL                   //SYSIN  DD  DSN=MYPROG,DISP=(OLD,KEEP)
 //SYSUT1   DD  UNIT=SYSDA,SPACE=(CYL,(1,1))   //S2  EXEC  PGM=IEWBLINK
     :                                         //SYSLIN  DD  DSN=MYOBJECT,DISP=OLD  
 //SYSUT7   DD  UNIT=SYSDA,SPACE=(CYL,(1,1))   //SYSLMOD  DD  DSN=MYLIB(PROG1),DISP=SHR
 //SYSPRINT DD  SYSOUT=A                       //SYSLIB  DD  DSN=SYS1.COBLIB,DISP=SHR
 //SYSLIN   DD  DSN=MYOBJECT,UNIT=SYSDA,SPACE=(CYL,1),DISP=(NEW,KEEP)



        Library Procedure                    +—————————————————————————————+
        —————————————————                    |         Instream JCL        |
                               | //S1  EXEC  COMPILE         |
                  |        :  (COBOL program A) |
  | //S2  EXEC  COMPILE         |
  |        :  (COBOL program B) |
     :                                       | //S3  EXEC  COMPILE         |
  |        :  (COBOL program C) |
                     +—————————————————————————————+
 
*Problems with Multiple Executions
Look now at the other problem encountered with the COMPILE procedure. When executed more than once, the SYSLIN DD either
  • Created multiple data sets with the same name
  • Generated a JCL error for duplicate data sets on volume


        Library Procedure                    +—————————————————————————————+
        —————————————————                    |         Instream JCL        |
                              | //S1  EXEC  COMPILE         |
                  |        :  (COBOL program A) |
  | //S2  EXEC  COMPILE         |
  |        :  (COBOL program B) |
                                             | //S3  EXEC  COMPILE         |
  |        :  (COBOL program C) |
                      +—————————————————————————————+
 
*Creating Flexible Procedures
As you see, the DDNAME parameter is one way to make your COMPILE procedure more flexible.
Let's examine this parameter in more detail before going on.

*Other Permissible Parameters
If the DDNAME is coded on a DD statement, the only other parameter permitted is the DCB.
And only these subparameters are permissible:
BLKSIZE
   BUFNO
      DIAGNS



*If DD Is Not Supplied
What happens if you code the DDNAME parameter and then don't supply the DD mentioned at execution?
The result is the system treats the data set as though it were defined as DD DUMMY.

*Implications of DD DUMMY
Remember that DD DUMMY means:
  • No device or storage is allocated.
  • No disposition processing occurs.
  • Input operations cause EOF and output operations are ignored.




Topic 3.2: Using DDNAME

DDNAME Is Not Always the Answer
The DDNAME parameter is not useful for all DD statements in a procedure. As such, it defeats the purpose of procedures — reusable JCL already coded.
Yet, the DDNAME parameter is great under certain circumstances. You already saw one for the COMPILE procedure, but let's see another.

*Another Use for DDNAME
Many programs and utilities expect user-supplied input from a DD statement other than SYSIN.
In these cases, you can create a procedure with DDNAME=SYSIN and establish consistency.
Let's set up a procedure this way.


*The Benefits of DDNAME
As you can see, the DDNAME parameter can be very useful in procedures.
It lets you wait until execution to define the data set. However, this does put more responsibility on the users of the procedure.
It can also be helpful for establishing standards or conventions in your procedures. For example, all input will come from SYSIN.

Topic 3.3: Unit 3 Summary

In this unit, you learned the following:
  • The DDNAME parameter is an optional keyword parameter of the DD statement. With it, you may put off defining the entire data set attributes until the job step executes.

  • If the DDNAME is coded on a DD statement, the only other parameter permitted is the DCB.

  • If you fail to code the DD statement named in the DDNAME parameter, the system assumes DD DUMMY for the data set.


Unit 4. Symbolic Parameters



In this unit, you will learn another way to solve the problems that were identified with the COMPILE procedure. You will learn how using symbolic parameters allows you to specify values to be supplied later — when the job is run.

After completing this unit, you should be able to:
  • Explain how symbolic parameters are used

  • Define symbolic parameters


Topic 4.1: Using Symbolic Parameters

*The Problems with the COMPILE Procedure
In a previous unit, these problems with the procedure COMPILE were identified:
Problem 1:
The SYSLIN statement does not pass the data set's attributes to the next step. Thus, subsequent steps will not find the data set and the run will terminate.
Problem 2:
The SYSLIN statement specifies a data set name of MYOBJECT. This forces every user of the procedure to use the same data set.

DDNAME Is One Solution
The DDNAME parameter you saw in the previous unit may be used to postpone defining the object module until execution. But this places the entire burden of coding the DD statement on the user of the procedure.
In this unit you'll see another way to get the desired outcome!



*Problem 3
The same SYSLIN statement also specifies DISP=(NEW,KEEP). If you execute COMPILE more than once in the same job, one of two things may happen.
See if you remember them...



*An Alternative Solution
Clearly, you should be able to specify your own data set name and data set disposition every time the procedure is called. Defining the complete DD statement with the DDNAME parameter shouldn't be necessary!
Otherwise, it won't be very convenient to use the same procedure over and over.
There is a way. The three problems presented here can be overcome through the use of symbolic parameters.

*Symbolic Parameters
As you learned in an earlier course, symbolic parameters are coded in JCL statements to allow specific values to be supplied later — when the job is run.
Let's review how symbolic parameters work. Then you'll examine the rules in detail.

Note: The use of symbolic parameters is not restricted to procedures. Later, you'll look at the SET statement which can be used to assign values to symbolic parameters anywhere in your JCL.
For now, we'll concentrate on the use of symbolic parameters in procedures.


    //COMPILE    PROC
    //STEP1  EXEC  PGM=IGYCRCTL
    //SYSUT1   DD  UNIT=SYSDA,SPACE=(CYL,(1,1))
        :
    //SYSUT7   DD  UNIT=SYSDA,SPACE=(CYL,(1,1))
    //SYSPRINT DD  SYSOUT=A
   
    //  PEND
*Replacing the Data Set Name
Here is the procedure COMPILE. A symbolic parameter is placed where the data set name usually goes.



    //COMPILE    PROC
    //STEP1  EXEC  PGM=IGYCRCTL
    //SYSUT1   DD  UNIT=SYSDA,SPACE=(CYL,(1,1))
        :
    //SYSUT7   DD  UNIT=SYSDA,SPACE=(CYL,(1,1))
    //SYSPRINT DD  SYSOUT=A
    //SYSLIN   DD  DSN=&OBJECT,UNIT=SYSDA,SPACE=(CYL,1),DISP=(NEW,KEEP)
    //  PEND
*Assigning the Value
Look at the example above. The EXEC statement is used to assign a value to the symbolic parameter in the DSN field.
The value in the EXEC statement is substituted for the symbolic parameter at execution time.



Topic 4.2: Defining Symbolic Parameters

*Defining the Parameters
As you can see, symbolic parameters allow procedures to be modified at execution time.
Now, look at how symbolic parameters are defined.

*Naming Conventions
Symbolic parameters follow typical naming conventions:
  • Start with an ampersand (&).
  • Follow the & by 1 - 8 alphanumeric or national characters.
  • The first character following the ampersand must be alphabetic or national.




*How Symbolic Parameters Are Used
Symbolic parameters can only be used to assign values to subparameters in the JCL operand field:
//name  operation  operands  comments

*How Symbolic Parameters Are Not Used
Symbolic parameters cannot be used for
  • EXEC statement parameter and subparameter keywords
  • DD or JOB statement keywords in procedures or jobs initiated with a START command
  • Name or operation fields of a JCL statement
  • Instream data
Remember that if you use a JCL symbol that has the same name as a system symbol, the JCL symbol will override the system symbol.



    //COMPILE    PROC
    //STEP1  EXEC  PGM=IGYCRCTL
    //SYSUT1   DD  UNIT=SYSDA,SPACE=(CYL,(1,1))
        :
    //SYSUT3   DD  UNIT=SYSDA,SPACE=(CYL,(1,1))
    //SYSPRINT DD  SYSOUT=A
   
    //  PEND
*Substituting Different Values
You can substitute different values for the DISP and DSN symbols at execution time. This will avoid the problems you saw earlier with the procedure COMPILE.



*One Final Note
To increase the usability of JCL and procedures, many installations establish a standard set of symbolic parameters.
Refer to your installation guidelines for more information on symbolic parameters.

Topic 4.3: Unit 4 Summary

In this unit, you learned the following:
  • Symbolic parameters are coded in JCL statements to allow specific values to be supplied later — when the job is run.

  • Symbolic parameters follow typical naming conventions.

  • Symbolic parameters can only be used to assign values to subparameters in the JCL operand field.


Unit 5. Assigning Execution Values



In the last unit, you saw how to include symbolic parameters in your procedure.
In this unit, you will learn how to assign values to those parameters using the EXEC and the SET statements. You will also learn about temporary data sets, and how the JOB listing looks when symbolic parameters are used.

After completing this unit, you should be able to:
  • Assign values to symbolic parameters using the EXEC statement

  • Create a temporary data set by omitting a value for the DSN parameter

  • Assign values to symbolic parameters using the SET statement

  • Interpret messages in the JOB listing where symbolic parameters were used


*Three Ways to Assign Values
There are three ways to assign values to symbolic parameters:
1) Via the EXEC statement that invokes a procedure
2) Using a SET statement to establish a value before the statement with the symbolic parameter is executed
3) Via the PROC statement that defines a procedure
We'll look at the first two methods in this unit. The last method is covered later in this course.

Topic 5.1: Assigning via the EXEC Statement

    //COMPILE    PROC
    //STEP1  EXEC  PGM=IGYCRCTL
    //SYSUT1   DD  UNIT=SYSDA,SPACE=(CYL,(1,1))
        :
    //SYSUT7   DD  UNIT=SYSDA,SPACE=(CYL,(1,1))
    //SYSPRINT DD  SYSOUT=A
    //SYSLIN   DD 
    //  PEND
*The COMPILE Procedure
Here is the procedure COMPILE again with its three symbolic parameters.

    //COMPILE    PROC
    //STEP1  EXEC  PGM=IGYCRCTL
    //SYSUT1   DD  UNIT=SYSDA,SPACE=(CYL,(1,1))
        :
    //SYSUT7   DD  UNIT=SYSDA,SPACE=(CYL,(1,1))
    //SYSPRINT DD  SYSOUT=A
    //SYSLIN   DD  DSN=&OBJECT,UNIT=SYSDA,SPACE=(CYL,1),DISP=(&STA,&DSP)
    //  PEND
  
*Format for the EXEC Statement
You assign values to the symbolic parameters in COMPILE by including the following information in your EXEC statement:
  • The symbolic parameter name without the ampersand (&)
  • Followed by an equal sign (=)
  • Followed by the value you want the parameter to have


Topic 5.1.1: Fixing the COMPILE Procedure

*Solving the Problems
You need to learn all the ins and outs of how symbolic parameter values are coded.
But first, let's see if these three symbolic parameters can solve all the outstanding issues with the COMPILE procedure.

*Multiple Data Sets
The other part of the previous problem is that multiple data sets with the same name could be created, causing:
  • Duplicate data sets error messages
  • Multiple data sets across many volumes
All three symbolic parameters work together to circumvent this situation:
&OBJECT - can specify different data set names
&STA - can access existing data sets
&DSP - can pass and delete the data set in the run, avoiding duplication

Topic 5.1.2: Coding Rules

*Value Contains Special Characters
Now let's get on with the ins and outs of how symbolic parameters are coded.
If the value coded for a symbolic parameter contains special characters (this includes blanks), it must be enclosed in apostrophes.
For example: EXEC COMPILE,OBJECT='MY.OBJECT'

*Value Contains Apostrophes
To code an apostrophe as part of the value, you must code two consecutive apostrophes.
For example: EXEC COMPILE,OBJECT='PAT''SFILE'



*Value Can't Continue on Second Line
Here's another thing to remember when you're assigning values to a symbolic parameter:
The maximum length of a symbolic parameter value is 255. However, the value can't continue onto another line.
For example, the following statement is incorrect:
//S1  EXEC  COMPILE,OBJECT='MY.
//  OBJECT',STA=NEW,DSP=KEEP
Why? The assignment OBJECT='MY.OBJECT' needs to be coded all on one line.



    //COMPILE    PROC
    //STEP1  EXEC  PGM=IGYCRCTL
    //SYSUT1   DD  UNIT=SYSDA,SPACE=(CYL,(1,1))
        :
    //SYSUT7   DD  UNIT=SYSDA,SPACE=(CYL,(1,1))
    //SYSPRINT DD  SYSOUT=A
    //SYSLIN   DD  DSN=&OBJECT,UNIT=SYSDA,SPACE=(CYL,1),DISP=(&STA,&DSP)
    //  PEND
    //S1  EXEC COMPILE,OBJECT=MYOBJECT,STA=NEW,DSP=PASS
*All Symbolic Parameters Must Be Assigned Values
A third point to keep in mind when executing a procedure that contains symbolic parameters is that in most cases, your EXEC statement needs to contain a value for each of the symbolic parameters in the called procedure.

    //COMPILE    PROC
    //STEP1  EXEC  PGM=IGYCRCTL
    //SYSUT1   DD  UNIT=SYSDA,SPACE=(CYL,(1,1))
        :
    //SYSUT7   DD  UNIT=SYSDA,SPACE=(CYL,(1,1))
    //SYSPRINT DD  SYSOUT=A
   
    //  PEND
   
*Three Symbolic Parameters, Three Assignments
Note the example above. The procedure COMPILE contains three symbolic parameters. The EXEC statement that calls COMPILE contains all three value assignments.

    //COMPILE    PROC
    //STEP1  EXEC  PGM=IGYCRCTL
    //SYSUT1   DD  UNIT=SYSDA,SPACE=(CYL,(1,1))
        :
    //SYSUT7   DD  UNIT=SYSDA,SPACE=(CYL,(1,1))
    //SYSPRINT DD  SYSOUT=A
    //SYSLIN   DD  DSN=&OBJECT,UNIT=SYSDA,SPACE=(CYL,1),DISP=(&STA,&DSP)
    //  PEND
    //S1  EXEC COMPILE,OBJECT=MYOBJECT,STA=NEW,DSP=PASS
*Values Can Be Assigned in Any Order
There is one more thing to know about assigning values in an EXEC statement:
You can assign values to your symbolic parameters in any order.
//S1  EXEC COMPILE,STA=NEW,OBJECT=MYOBJECT,DSP=PASS
//S1  EXEC COMPILE,DSP=PASS,STA=NEW,OBJECT=MYOBJECT



*Values Must Be Supplied
What happens when you don't supply a value for one or more of the symbolic parameters in your procedure? You'll get a JCL error, along with the message:
INCORRECT USE OF AMPERSAND IN THE XXXX FIELD
                                   


Topic 5.2: Temporary Data Sets

*Values Must Be Supplied, Except...
Ah, but JCL is just like life... there are always exceptions.
There is one parameter that allows you to omit a value for its symbolic parameter at execution time: the DSN parameter.
What happens when you put a symbolic parameter in the DSN field and then don't supply a value for it?
The system assumes you are creating a temporary data set. Let's digress for a moment and see how temporary data sets are named.

*Creating a Temporary Data Set
Temporary data sets can be created in the following ways:
Examine the following table
Format Use
DSN=&&name Instream JCL or procedure
DSN=&name As a symbolic parameter in a procedure
DSN= Instream JCL or procedure


*A Name Is Assigned
Temporary data sets exist for the duration of the job. They are assigned a complete name by the system, using this format:
SYSyyddd.Thhmmss.RAnnn.jobname.dsn
+—————————————————————————————+ |
            |                   +—> Name in DSN field
            V                       without ampersand
   System-assigned prefix
including date, time, and jobname



*Why Not &&?
There are two reasons why temporary data set names do not have to start with two ampersands (&&).
A symbolic parameter used for the DSN value in a procedure is treated as a temporary data set name if no value is assigned to it.
And DSN= without a name is also assumed to be a temporary data set.
Both get a system assigned name of:
SYSyyddd.Thhmmss.RAnnn.jobname.Rmmmmmmm
The last level is a prefix R and a number that is one higher than the last temporary data set name.
Now look at a few sample EXEC statements while you think about the rules you've seen so far.



    //COMPILE    PROC
    //STEP1  EXEC  PGM=IGYCRCTL
    //SYSUT1   DD  UNIT=SYSDA,SPACE=(CYL,(1,1))
        :
    //SYSUT7   DD  UNIT=SYSDA,SPACE=(CYL,(1,1))
    //SYSPRINT DD  SYSOUT=A
    //SYSLIN   DD  DSN=&OBJECT,UNIT=SYSDA,SPACE=(CYL,1),DISP=(&STA,&DSP)
    //  PEND
   
*Values and Parameters Must Match
In this example the EXEC statement is in error — it assigns a symbolic parameter that isn't in the procedure.
You know that every symbolic parameter has to have a value. The reverse is also true. Every value you assign must correspond to a symbolic parameter in the procedure.

Topic 5.3: Assigning via the SET Statement

*The Advantage of Using SET
Now let's take a look at the SET statement.
The SET statement works (and is coded) in much the same way as the EXEC statement; both can be used to assign values to symbolic parameters.
The main advantage of the SET statement is that it can be used to define symbolic parameters.
As you may recall from the beginning of this unit, symbolic parameters can be used outside of procedures.

  //MYJOB  JOB
      :
  //SETX   SET  NAME=TEST3
      :
      :
  //SYSUT1 DD   DSN=&NAME
*An Example
For example, you may want to run the same job using different input data sets. You can code the DSN parameter as a symbolic parameter on the DD statement, using a SET statement to designate a data set name when the job is executed.
For the code above, the TEST3 data set will be used when the job is run.

*The Statement Format
The format of the SET statement is:
//name  SET  symbolic-parameter=value
The same basic rules for coding the symbolic parameter value on the EXEC statement apply to the SET statement.

*Coding Rules for SET
There are a few rules to keep in mind when using the SET statement with symbolic parameters:
  • The SET statement can be placed anywhere in the jobstream. It will affect only those symbolic parameters that follow the SET statement.
  • There is no limit to the number of SET statements in a job.
  • The values assigned in a SET statement remain in effect until they're overridden by another SET statement, a PROC statement, or by an EXEC statement.
  • The SET statement cannot be used for conditional execution. If you try to use a SET statement in an IF/THEN/ELSE/ENDIF construct, the SET statement assignment will always be executed.


*Uses of SET
SET statements have many uses both within and outside of procedures. Refer to your installation guidelines and JCL manuals for more information on using the SET statement and symbolic parameters.
How are the values assigned to a symbolic parameter indicated in the JOB listing?
Here's the way it works...

Topic 5.4: Symbolic Parameters in the JOB Listing

*Output for Symbolic Parameters
When you execute a procedure that contains symbolic parameters you'll see the following things on the JOB listing:
  • The expansion of the JCL statements from the procedure
  • The message SUBSTITUTION JCL
  • A line or lines showing the entire operand field of the statement where substitutions were made for symbolic parameters


    //COMPILE    PROC
    //STEP1  EXEC  PGM=IGYCRCTL
    //SYSUT1   DD  UNIT=SYSDA,SPACE=(CYL,(1,1))
        :
    //SYSUT7   DD  UNIT=SYSDA,SPACE=(CYL,(1,1))
    //SYSPRINT DD  SYSOUT=A
    //SYSLIN   DD  DSN=&OBJECT,UNIT=SYSDA,SPACE=(CYL,1),DISP=(&STA,&DSP)
    //  PEND
   
*Breaking Down the Message
The JCL above generates this message:
9 IEF653I SUBSTITUTION JCL - DSN=MYOBJ,UNIT=SYSDA,SPACE=(CYL,1),DISP=(NEW,PASS)
Let's look more closely at this message.

*Sequence Number
The JCL generates this message:
IEF653I SUBSTITUTION JCL - DSN=MYOBJ,UNIT=SYSDA,SPACE=(CYL,1),DISP=(NEW,PASS)
The number at the beginning of the message, 9, shows the sequence number of the affected statement.
The prior page of the listing displays this line in the expanded JCL statements.

*Message Number and Description
The JCL generates this message:
9 - DSN=MYOBJ,UNIT=SYSDA,SPACE=(CYL,1),DISP=(NEW,PASS)
The message number and description follow next. You can look in your programmer's guide for a more detailed explanation of this message.

*Operand Field
The JCL generates this message:
9 IEF653I SUBSTITUTION JCL -
Finally, there is the complete operand field of the statement.
All parameters display, whether or not substitutions were made.



Topic 5.5: Unit 5 Summary

In this unit, you learned the following:
  • There are three ways to assign values to symbolic parameters: 1) via the EXEC statement that invokes a procedure, 2) using a SET statement to establish a value before the statement with the symbolic parameter is executed, and 3) via the PROC statement that defines a procedure.
  • You assign values to the symbolic parameters by including in your EXEC statement: the symbolic parameter name without the ampersand (&), followed by an equal sign (=), followed by the value you want the parameter to have.
  • The SET statement works (and is coded) in much the same way as the EXEC statement: both can be used to assign values to symbolic parameters. The main advantage of the SET statement is that it can be used to define symbolic parameters.
  • The format of the SET statement is:
    //name  SET  symbolic-parameter=value
  • When you execute a procedure that contains symbolic parameters you'll see the following things on the JOB listing: the expansion of the JCL statements from the procedure, as usual, followed by (on the next page) the message SUBSTITUTION JCL, followed by a line or lines showing the entire operand field of the statement where substitutions were made for symbolic parameters.


Unit 6. Assigning Defaults and No Value



You saw before that forgetting to assign a value to a symbolic parameter at execution time generates an error message.
In this unit, you will learn how to avoid this error by either 1) assigning default values to each symbolic parameter, or 2) nullifying a symbolic parameter to avoid having to assign a value.

After completing this unit, you should be able to:
  • Assign default values to symbolic parameters

  • Nullify symbolic parameters


Topic 6.1: Assigning Default Values

*Establishing Defaults
You saw before that forgetting to assign a value to a symbolic parameter at execution time generates an error message.
There is a way to avoid this error message, and make your life easier at the same time: establish a default value for each of your symbolic parameters.

*What Is a Default?
The phrase default value refers to the most common value for a given parameter — the value it usually takes.
IF you give one of your symbolic parameters a default value
AND you don't supply another value when you execute the procedure
THEN your parameter will be assigned the pre-set value automatically.


*Using the PROC Statement
As you know, the EXEC statement is generally used to assign values at execution time.
For default symbolic parameter values, the PROC statement is typically used.
Note that the SET statement can also be used to assign values to symbolic parameters.
We'll be focusing on the PROC statement in this unit.

PROC vs. EXEC
The PROC statement takes the form:
//COMPILE  PROC  
Whereas the EXEC statement looks like this:
//  EXEC  
Notice that the EXEC statement symbolic parameter assignments are separated from the procedure name by a comma, without spaces.



*Things to Remember
Here are a few additional things to remember about using default values with symbolic parameters:
1. Default values can be listed on the PROC statement in any order you like.
2. Assignment of default values is entirely optional. You can supply defaults for all, some, or none of your symbolic parameters.
Keep in mind, however, that all symbolic parameters (except for DSN) must have an assigned value before the procedure is executed, or a JCL error will result.

*More Things to Remember
3. On the EXEC statement, you may choose NOT to supply a value for a symbolic parameter that already has a suitable default value.
4. EXEC statement assigned values take precedence over PROC statement default values, which in turn override SET statement values.

Question 50

*Considering the Rules for Defaults
Think about how default rules might affect a procedure with the following PROC statement, then answer the questions on the following pages.
//COMPILE  PROC  OBJECT=YOUROBJ,STA=MOD,DSP=PASS



Topic 6.2: Nullifying Parameters

*Assigning No Value
Once again, recall that if a value is not supplied for one of your symbolic parameters, you'll get this JCL error message (unless the missing value was for the DSN field):
INVALID AMPERSAND IN THE XXXX FIELD
Of course, you can avoid this error message by:
  • Assigning a value at execution time with the EXEC or SET statement, or
  • Assigning a default value with the PROC statement.
But what if you want one or more symbolic parameters to have no value at all? That is, if you want the system to assign the default value to the missing parameter?

*Parameter Name=
To show that you intend to supply no value for a symbolic parameter, use this format:
  • The parameter name
  • Followed by an equal sign (=)
  • With nothing following the equal sign
This nullifies the symbolic parameter.

*System Uses the Default Value
When you nullify a symbolic parameter, you are assigning it the value of NULL — no value.
This causes the system to use the default value for the parameter. The following pages explain the difference as the system sees it...

Note: Some keyword parameters do not allow null values. Check your JCL manuals if you're not sure a null value is valid.


  //COMPILE    PROC
  //STEP1  EXEC  PGM=IGYCRCTL
  //SYSUT1   DD  UNIT=SYSDA,SPACE=(CYL,(1,1))
  //SYSUT2   DD  UNIT=SYSDA,SPACE=(CYL,(1,1))
      :
  //SYSUT7   DD  UNIT=SYSDA,SPACE=(CYL,(1,1))
  //SYSPRINT DD  SYSOUT=A
  //SYSLIN  DD  DSN=&OBJECT,UNIT=SYSDA,SPACE=(CYL,1),DISP=(&STA,&DSP)
  //  PEND
  
*Execution with No Values
The EXEC statement causes the PROC to be executed with these values substituted in the SYSLIN statement:
//SYSLIN  DD  DSN=PROGA,UNIT=SYSDA,SPACE=(CYL,1),DISP=(&STA,&DSP)



  //COMPILE    PROC
  //STEP1  EXEC  PGM=IGYCRCTL
  //SYSUT1   DD  UNIT=SYSDA,SPACE=(CYL,(1,1))
  //SYSUT2   DD  UNIT=SYSDA,SPACE=(CYL,(1,1))
      :
  //SYSUT7   DD  UNIT=SYSDA,SPACE=(CYL,(1,1))
  //SYSPRINT DD  SYSOUT=A
  //SYSLIN  DD  DSN=&OBJECT,UNIT=SYSDA,SPACE=(CYL,1),DISP=(&STA,&DSP)
  //  PEND
  
*Execution with Nullified Values
In this example, the EXEC statement above will cause the following SYSLIN values to be substituted:
//SYSLIN  DD  DSN=MYOBJECT,UNIT=SYSDA,SPACE=(CYL,1),DISP=(,KEEP)
You can see that the &STA value is nullified — it doesn't even appear in the SYSLIN statement.



*The Case for Nullifying
To summarize:
If you don't assign a value to a symbolic parameter, you get an error message.
If you nullify a symbolic parameter, the system assigns a default value.
Compare the two examples you just saw.

*Illustrating the Difference
//SYSLIN DD DSN=&OBJECT,UNIT=SYSDA,SPACE=(CYL,1),DISP=(&STA,&DSP)
Example 1:
//    EXEC  COMPILE,OBJECT=PROGA
The above SYSLIN statement executes with DISP=(&STA,&DSP) as a parameter, and causes an error in the DISP field.
Example 2:
//    EXEC  COMPILE,OBJECT=MYOBJECT,STA=,DSP=KEEP
In this example, the &STA value is nullified. The statement executes with DISP=(,KEEP). Therefore, the system assigns the default status of NEW to the data set.

  //COMPILE    PROC  OBJECT=MYOBJECT,STA=NEW,DSP=PASS
  //STEP1  EXEC  PGM=IGYCRCTL
  //SYSUT1   DD  UNIT=SYSDA,SPACE=(CYL,(1,1))
  //SYSUT2   DD  UNIT=SYSDA,SPACE=(CYL,(1,1))
      :
  //SYSUT7   DD  UNIT=SYSDA,SPACE=(CYL,(1,1))
  //SYSPRINT DD  SYSOUT=A
  //SYSLIN  DD  DSN=&OBJECT,UNIT=SYSDA,SPACE=(CYL,1),DISP=(&STA,&DSP)
  //  PEND
  //    EXEC  COMPILE,OBJECT=PROGA
*More Examples
Here are two examples that use the EXEC statement to nullify a symbolic parameter:
//   EXEC  COMPILE,OBJECT=MINE,STA=
//   EXEC  COMPILE,DSP=,STA=OLD
In the first example, the null value is assigned to STA. In the second example, DSP is explicitly given the null value.



Topic 6.3: Unit 6 Summary

In this unit, you learned the following:
  • The phrase default value refers to the most common value for a given parameter — the value it usually takes.

  • For default symbolic parameter values, the PROC statement is typically used.

  • The PROC statement takes the form:

    //COMPILE  PROC  OBJECT=YOUROBJ,STA=MOD,DSP=PASS

  • Whereas the EXEC statement looks like this:

    //  EXEC  COMPILE,OBJECT=MYOBJECT,STA=NEW,DSP=KEEP

  • To show that you intend to supply no value for a symbolic parameter, give the parameter name followed by an equal sign (=) with nothing following the equal sign.

  • When you nullify a symbolic parameter, you are assigning it the value of NULL — no value. This causes the system to use the default value for the parameter.


Unit 7. Concatenating Symbolic Parameters



In the first part of this unit, you will see how to concatenate symbolic parameters and why it is a good idea to do so sometimes.
In the final section, you will learn some advanced applications of symbolic parameters.

After completing this unit, you should be able to:
  • Concatenate symbolic parameters

  • Use symbolic parameters to add and comment out parameters on JCL statements


Topic 7.1: Rules for Concatenation

*What Is Concatenation?
A symbolic parameter can be combined with another symbolic parameter or a character string to produce a new value. The operation that provides these combinations is called concatenation.
A period (.) is the concatenation operator.
Let's look at some examples to help make this clearer.

*Concatenation Examples
Here are a few symbolic parameters and their possible values.
Examine the following table
Symbolic Parameter Value
&VAL ABCD
&STA 1234
&DO (MEM1)
&VAL.&DO ABCD(MEM1)
&STA.&DO 1234(MEM1)
&VAL.&STA.&DO ABCD1234(MEM1)
&VAL.HGI ABCDHGI

The fourth, fifth, and sixth examples concatenate symbolic parameters. The last joins a symbolic parameter with a character string HGI.


*The Period Is Optional
The last two examples could also be concatenated without using the operator. That is...
Examine the following table
2.&LBL 2&LBL
&LIB.&NAME &LIB&NAME

... are all valid concatenations.
Let's look at this a little closer.

*Clear without the Period
The concatenation symbol (.) may be omitted when the concatenation is unambiguous. Three of the four examples you saw before are unambiguous.
Examine the following table
&VAL.&DO &VAL&DO
&STA.&DO &STA&DO
&VAL.&STA.&DO &VAL&STA&DO

The combination of symbolic parameters is clear whether or not the period is present. However...

*Unclear without the Period
The fourth concatenation &VAL.HGI becomes ambiguous if you omit the period: &VALHGI.
Without the period, the concatenated character string looks as if &VALHGI is another symbolic parameter.

*Two Periods for One
One other bit of information involves the period.
If you want a period to appear in the resulting concatenated value, you must code two periods. Here are two examples with the parameters you've seen.
Examine the following table
Symbolic Parameter Value
&VAL ABCD
&DO (MEM1)

&VAL..&DO gives ABCD.(MEM1)
&VAL..HGI gives ABCD.HGI



  //COMPLINK  PROC  OBJ=LOADSET,MEM=TEMPNAME
  //COMP    EXEC  PGM=IGYCRCTL
  //SYSUT1    DD  UNIT=SYSDA,SPACE=(CYL,2)
      :
  //SYSUT7    DD  UNIT=SYSDA,SPACE=(CYL,2)
  //SYSPRINT  DD  SYSOUT=A
  //SYSLIN  DD  DSN=&OBJ,UNIT=SYSDA,SPACE=(CYL,1),DISP=(NEW,PASS)
  //LINK    EXEC  PGM=IEWBLINK
  //SYSPRINT  DD  SYSOUT=A
  //SYSUT1    DD  UNIT=SYSDA,SPACE=(CYL,1)
 
  //SYSLIB    DD  DSN=SYS1.COBLIB,DISP=SHR
  //SYSLIN    DD  DSN=&OBJ,DISP=(OLD,DELETE)
*Using Concatenation
Here is the COMPLINK procedure you've seen before.
Notice that the DSN on SYSLMOD in the LINK step needs to be filled in. This name is to be a combination of procedure library (&LIB) and member name (&MEM).
It's an opportunity to concatenate two symbolic parameters!



*A "Must Concatenate" Situation
The previous example showed a situation where concatenating symbolic parameters was a convenience. Let's consider a situation where it is a must.
Concatenation is the best approach when you are coding symbolic parameters as part of a parameter that does not have default values for its subparameters.
One example of such a parameter is SPACE — using symbolic parameters for the primary and secondary allocations.
For example: SPACE=(TRK,(&PRI,&SEC))
As you know, the system does not have default values for omitted primary or secondary subparameters.

*Another Possible Error
SPACE=(TRK,(&PRI,&SEC))
For values &PRI=1 and &SEC=1the result is SPACE=(TRK,(1,1))
With values &PRI=1 and &SEC=the result is SPACE=(TRK,(1,))
The second example, where &SEC is nullified, causes a JCL error to occur!

*Concatenation Is the Solution
SPACE=(TRK,(&PRI,&SEC))
Concatenating &PRI and &SEC is the coding approach to use so JCL errors can be avoided.
SPACE=(TRK,(&PRI&SEC))



*Another Option
Another valid parameter assignment for SPACE=(TRK,(1,1)) is:
&PRI='1,' and &SEC=1
One parameter or the other must contain the needed comma.

Topic 7.2: Applications for Symbolic Parameters

*Using Symbolic Parameters to Modify Statements
Symbolic parameters can help you modify JCL statements in ways you didn't think were possible!
Besides assigning values at execution time, you can:
  • Cause everything following a given parameter to be treated as a comment
  • Change or add parameters without rewriting the entire procedure


  //COMPILE  PROC  OBJECT=MYOBJECT,STA=NEW,DSP=PASS
  //STEP1  EXEC  PGM=IGYCRCTL
  //SYSUT1   DD  UNIT=SYSDA,SPACE=(CYL,(1,1))
       :
  //SYSUT7   DD  UNIT=SYSDA,SPACE=(CYL,(1,1))
  //SYSPRINT DD  SYSOUT=A
  //SYSLIN  DD  DSN=&OBJECT,UNIT=SYSDA,SPACE=(CYL,1),DISP=(&STA,&DSP)
  //  PEND
*Revisiting the COMPILE Procedure
Look at the procedure COMPILE again.
The SYSLIN statement always creates a new data set. But what if you had an existing data set that you wanted to access instead?
Let's take a closer look at this problem, and see what can be done.

  //COMPILE  PROC  OBJECT=MYOBJECT,STA=NEW,DSP=PASS
  //STEP1  EXEC  PGM=IGYCRCTL
  //SYSUT1   DD  UNIT=SYSDA,SPACE=(CYL,(1,1))
       :
  //SYSUT7   DD  UNIT=SYSDA,SPACE=(CYL,(1,1))
  //SYSPRINT DD  SYSOUT=A
  //SYSLIN  DD  DSN=&OBJECT,UNIT=SYSDA,SPACE=(CYL,1),DISP=(&STA,&DSP)
  //  PEND
*Accessing an Existing Data Set
Suppose that you have an existing data set MYOBJ. It resides on DISK01 and is not cataloged.
You want to access it from SYSLIN.



  //COMPILE  PROC  OBJECT=MYOBJECT,STA=NEW,DSP=PASS
  //STEP1  EXEC  PGM=IGYCRCTL
  //SYSUT1   DD  UNIT=SYSDA,SPACE=(CYL,(1,1))
       :
  //SYSUT7   DD  UNIT=SYSDA,SPACE=(CYL,(1,1))
  //SYSPRINT DD  SYSOUT=A
  //SYSLIN  DD  DSN=&OBJECT,UNIT=SYSDA,SPACE=(CYL,1),DISP=(&STA,&DSP)
  //  PEND
*The Necessary Code
To access your data set on DISK01 you need the following:
//SYSLIN  DD  DSN=MYOBJ,UNIT=SYSDA,VOL=SER=DISK01,DISP=OLD

*But How Can It Be Implemented?
You could code a whole new procedure with another SYSLIN for this special case. However, that defeats the purpose of having library procedures containing reusable code.
You could also override the DD statement — but you haven't learned how to do that yet.
The symbolic parameters coded on the SYSLIN statement provide the key to an easy short-cut solution.

*Simple Character Substitution
The power of symbolic parameters lies in how assigned values are handled by the system.
When you assign a value to a symbolic parameter, the system does a simple character substitution. The value is placed in the JCL statement exactly as you coded it.
Let's look at a DD statement from another procedure and see how symbolic parameters can be coded to get some quite unique results.

  //DDOUT  DD  DSN=&OUTFILE,UNIT=SYSDA,DISP=(&STA,&DSP),SPACE=(CYL,1)
*Using Symbolic Parameters Creatively
Above is a DD statement that normally creates a new data set.
It contains three symbolic parameters to change the DSN and DISP parameters.
You'll look at three situations with this DD:
  • Adding a DCB parameter
  • Commenting out the SPACE parameter to use an existing data set that is cataloged
  • Commenting out the original SPACE parameter to add a new one




*Laying the Ground Work
These questions showed:
1. The coding of a space after a parameter stops the operand field and starts the comments field.
2. Whatever is assigned to a symbolic parameter is substituted character-by-character.
With these points in mind, let's get on with the first situation adding a DCB parameter.

  //COPY  PROC
     :
  //DDOUT  DD  DSN=&OUTFILE,UNIT=SYSDA,DISP=(&STA,&DSP),SPACE=(CYL,1)
  // PEND
  //EXAMPLE1  EXEC  COPY
*Setting Up the Parameters
Assume that the procedure represented above performs a copying function. DDOUT is the only DD statement you need to be concerned with in this section. The others won't be shown.
Let's assign these values to the parameters:
DSN of RPS.NMST and DISP of NEW and KEEP
And let's add a DCB of RECFM=FB, LRECL=80, and BLKSIZE=8000 after the DISP parameter.

  //COPY  PROC
     :
  //DDOUT  DD  DSN=&OUTFILE,UNIT=SYSDA,DISP=(&STA,&DSP),SPACE=(CYL,1)
  // PEND
 
*Coding a Subparameter as a Symbolic
The EXEC statement above starts the desired changes.
The DCB addition can easily be accomplished by coding a subparameter as a symbolic parameter! You can use the DSP symbolic parameter to insert the DCB information.
Let's look closely at this feature.

*Adding the Subparameter
//DDOUT  DD  DSN=&OUTFILE,UNIT=SYSDA,DISP=(&STA,&DSP),SPACE=(CYL,1)
To add a parameter after the DISP, these four characters (&DSP) must be replaced with:
  • KEEP                        - disposition for DISP
  • )                             - end parenthesis for DISP
  • ,                             - comma to separate DISP and next                                  parameter
  • DCB=(                       - start of DCB parameter
  • RECFM=FB,LRECL=80,BLKSIZE=8000 - subparameters for DCB
The remaining characters on the original DD statement follow and become part of the parameters:
  • )                              - end parenthesis for DCB
  • ,SPACE=(CYL,1)         - remaining parameters


*The Resulting Parameter
//DDOUT  DD  DSN=&OUTFILE,UNIT=SYSDA,DISP=(&STA,&DSP),SPACE=(CYL,1)
Thus, the DSP symbolic parameter becomes:




  //COPY  PROC
     :
  //DDOUT  DD  DSN=&OUTFILE,UNIT=SYSDA,DISP=(&STA,&DSP),SPACE=(CYL,1)
  // PEND
  //EXAMPLE1  EXEC  COPY,OUTFILE=RPS.NMST,STA=NEW,
 
*Remembering the Apostrophes
It's easy to just enclose the entire value in single quotes.
And remember: Whatever follows the symbolic parameter in the original DD statement follows immediately after the substituted characters. (In this example, it was the ending parenthesis and SPACE parameter.)

*Commenting Out a Parameter
The second situation to look at is commenting out the SPACE parameter to use an existing data set that is cataloged.
Coding a space rather than a comma after a parameter stops the operand field and begins the comments field.
This is the key to accomplishing this second change.

*The Space Begins a Comment
//DDOUT  DD  DSN=&OUTFILE,UNIT=SYSDA,DISP=(&STA,&DSP),SPACE=(CYL,1)
To comment out the SPACE parameter, these four characters (&DSP) must be replaced with:
  • KEEP      - disposition for DISP
  • )           - end parenthesis for DISP
  •              - space to end the operand field
Note that apostrophes must enclose the replacement characters.
All following characters of the original DD statement
        ),SPACE=(CYL,1)
thus become comments!



*Commenting AND Adding
Two of the three situations are complete:
  • Adding a DCB parameter
  • Commenting out the SPACE parameter to use an existing data set that is cataloged
  • Commenting out the original SPACE parameter to add a new one
The third requires the use of both previous techniques.

*Combining the Techniques
//DDOUT  DD  DSN=&OUTFILE,UNIT=SYSDA,DISP=(&STA,&DSP),SPACE=(CYL,1)
To comment out the SPACE parameter and add a new one, these four characters (&DSP) must be replaced with:
  • KEEP),                      - disposition for DISP
  • SPACE=(CYL,(1,1))     - the new SPACE parameter
  •                                 - space to end the operand field
Once again, all following characters of the original DD statement
        ),SPACE=(CYL,1)
become comments.



  //SYSLIN  DD  DSN=&OBJECT,UNIT=SYSDA,SPACE=(CYL,1),DISP=(&STA,&DSP)
*Accessing the Existing Non-Cataloged Data Set
You were to access from SYSLIN an existing data set named MYOBJ that resides on DISK01 and is not cataloged. The changes needed for SYSLIN involve two steps:
1. Comment out part of the statement — you don't need the SPACE parameter for an existing data set.
2. Add new values to the statement — you do need a VOL=SER parameter.
Let's do it.




*The Substitution
//SYSLIN  DD  DSN=&OBJECT,UNIT=SYSDA,SPACE=(CYL,1),DISP=(&STA,&DSP)
These seven characters (&OBJECT) must be replaced with the following to add a VOL=SER parameter and comment out the SPACE parameter:
  • MYOBJ                  - data set name
  • ,                         - comma to separate DSN and next parameter
  • VOL=SER=DISK01,UNIT=SYSDA,DISP=OLD - all required parameters
  •                            - space to end the operand field
All following characters of the original DD statement become comments:
        ,UNIT=SYSDA,SPACE=(CYL,1),DISP=(&STA,&DSP)



Topic 7.3: Unit 7 Summary

In this unit, you learned the following:
  • A symbolic parameter can be combined with another symbolic parameter or a character string to produce a new value. A period (.) is the concatenation operator.
  • The concatenation symbol (.) may be omitted when the concatenation is unambiguous. If you want a period to appear in the resulting concatenated value, you must code two periods.
  • Concatenation is the best approach when you are coding symbolic parameters as part of a parameter that does not have default values for its subparameters.
  • When you assign a value to a symbolic parameter, the system does a simple character substitution. The value is placed in the JCL statement exactly as you coded it.
  • The coding of a space after a parameter stops the operand field and starts the comments field.
  • You can add an extra parameter via an existing symbolic parameter. Just include the additional parameter in the character string.
  • When a symbolic parameter contains special characters (such as spaces, commas or parentheses) you must enclose the entire value in apostrophes (').
  • You can comment out parameters on the original DD statement with an existing symbolic parameter. Code a space rather than a comma at the end of the symbolic parameter. This ends the operand field.
  • You can add extra parameters and comment out existing ones in any desired combination with symbolic parameters.

 








 







 

 

No comments:

Post a Comment