apostila JCL

Embed Size (px)

DESCRIPTION

JCL

Citation preview

  • 1

    JCL

    Job Control Language

  • 2

    Unit I - Introduction to JCL Job Control Language 007

    Job Stream 008

    Job Steps 009

    Defining Job Control Statements 010

    The JOB Statement 011

    The EXEC Statement 012

    The DD Statement 013

    Grouping Programs 014

    Grouping Programs: An Example 015

    Other JCL Statements 016

    JCL Statement Fields 017

    Rules for Naming JCL Statements 019

    Rules for Writing JCL Statements 020

    Operation and Parameters Fields: An example 021

    Continuation statement and Comment Field: An Example 022

    Unit II - Analyzing Job Output SDSF 024

    PREFIX, OWNER and SET DISPLAY Commands 026

    Output Data Set panel 022

    JCL Statements Listing: // and XX 023

    Allocation and Termination Messages 024

    JCL error messages : An Example 025

    JCL error messages : An Example 026

  • 3

    Unit III - Coding JOB Statements

    Defining a JOB Statement 034

    Job Name 035

    Positional Parameters 036

    Job Accounting Information 037

    Coding Programmer Name 038

    Defining Keyword Parameters 039

    Coding the MSGLEVEL Parameter 040

    The MSGCLASS Parameter 042

    Defaults for MSGLEVEL & MSGCLASS 043

    COND Parameter 044

    COND Parameter: Examples 046

    CLASS Parameter 047

    NOTIFY Parameter 048

    PRTY Parameter 049

    REGION Parameter 050

    TIME Parameter 051

    TYPRUN Parameter 052

    The USER and PASSWORD Parameters 053

    Coding Multiple Keyword Parameters 054

    Unit IV - Coding EXEC Statements

    The EXEC Statement 056

    The Step Name 057

    The Positional Parameter 058

    Positional Parameter Coding Errors 059

    Keyword Parameters 060

    The PARM Parameter 061

    The COND Parameter 063

    COND Parameter Examples 064

    The COND Subparameters EVEN & ONLY 065

    Program Libraries 067

    Private Program Libraries 068

  • 4

    Unit V - Coding DD Statements

    The DD statement 071

    Using DDNAME in Programs 072

    DD Statement Parameters 073

    DD Statement Parameters DSN 074

    DD Statement Parameters DISP 075

    DD Statement Parameters UNIT 076

    DD Statement Parameters VOL 077

    DD Statement Parameters SPACE 078

    DD Statement Parameters DCB 079

    DD Statement Parameters SYSOUT 080

    Dummy Data Sets 081

    Data Set Concatenation 082

    Using Backward Reference 083

    Storage Dumps 087

    SMS Considerations 088

    Unit VI - Conditional Processing

    Syntax for the IF/THEN/ELSE/ENDIF Statement Construct 090

    Comparison Operators 092

    Logical Operators- AND, OR and NOT 093

    Relational-Expression Keywords 094

    Relational-Expression Keywords RC 095

    Relational-Expression Keywords ABEND and ABEND 096

    Relational-Expression Keywords ABENDCC 097

    Relational-Expression Keywords RUN and RUN 098

    IF/THEN/ELSE/ENDIF Examples 099

    Nesting Conditional Constructs 100

    The COND Parameter vs. Conditional Processing 101

  • 5

    Unit VII - Procedures

    Procedures 103

    Cataloged Procedure 104

    Nested Procedure 106

    Coding Changes 107

    Nullifying EXEC Statement Parameters 109

    Adding Parameters to a Procedure 110

    Sequencing Multiple Changes An Example 111

    Changing the DD Statement Parameters 112

    Overriding DD Statement Parameters 113

    Nullifying a DD Statement Parameter 115

    Addition DD Statements 117

    Overriding the DCB Parameter Example 118

    Symbolic Parameters 121

    Symbolic PGM Parameters 124

    Recognizing Default Values 125

    Nullifying Default Values 126

  • 6

    Unit 1 Introduction to JCL

    At the end of this unit, you will be able to:

    Explain the purpose and syntax of the JOB statement

    Define the JOB name

    Code positional parameters and keyword parameters

    Code the most commonly used keyword parameters on a JOB statement

    Complete the JOB statement

    Code additional JOB statement parameters

  • What is JCL?

    What is a job?

    Job Control Language (JCL) is a control language used to identify a job to an operating system and to describe the jobs requirements. It consists of a series of statements, each of which provides specific instructions or information for batch processing jobs.

    The three main types of JCL statements are: JOB, EXEC and DD

    JCL provides information to the system about job details://JOB1 JOB 504,SMITH//JOB1 JOB CLASS=A

    A job is a unit of work defined by a user to be accomplished by a computer, including computer programs, fi les or control statements.

    Job Control Language

    Notes: JCL is used to describe the work you want a system using multiple virtual storage (MVS) to perform.

    The three main types of JCL statements are: JOB, EXEC and DD JOB - It marks the beginning of a job and identifies the job name

    EXEC - It marks the beginning of a job step and specifies the name of the program to be executed

    DD - It describes data sets to be used within individual steps

    JCL provides information to the system about job details including:

    The programs to execute The location of the required data sets The department to be billed for CPU processing time The job class

    Job example:

    For example: The request to perform a task of updating one data set with information from another data set is called a job.

    JCL provides the operating system with information about the resources, programs, and data necessary to complete the job.

    7

  • One or more jobs placed in a series and ready to be submitted to the system are referred to as a job stream.

    Job Stream

    Notes: This series of jobs is entered through one input device. You can use JCL to structure a job stream.

    The JCL for each job begins with a JOB Statement.

    8

  • A job consists of one or more individual job steps.

    Each job step starts with an EXEC statement and is associated with the execution of one program.

    The data sets required for each job step can be defined using a DD statement.

    You then submit each job for processing as part of the job stream

    Job Steps

    Notes:

    9

  • //JOBNUM1 JOB 504,SMITH

    //STEP1 EXEC PGM=PROGRAMA

    //DD1 DD DSN=INPUT

    Job control statements define jobs and job steps.

    Job control statements are JCL statementscreated to prov ide the follow ing information: Programs to be executed Sequence of program execution Data sets required by the programs

    Defining Job Control Statements

    Notes: What details do you have to specify for each job? Each job requires you to specify at least the following:

    Job to begin (using a JOB statement) Program(s) to be executed (using EXEC statements) Data sets to be used (using DD statements)

    You can also add a null statement to mark the end of a job and comment statements to document your JCL statements.

    Job control statements may provide other kinds of information as well. For example, a job control statement can specify how the system should process a job by providing accounting information

    10

  • The JOB statement is the f irst control statement in a job. It marks the beginning of a job and specif iesthe job name.

    The JOB statement may also prov ide details and parameters that relate to the overall job, such asaccounting information and condit ions for job termination.

    //JOBNUM2 JOB 600,JONESParts of a Job

    End of Job marker

    //JOBNUM1 JOB 504,SMITH//STEP1 EXEC PGM=PROGRAMA//DD1 DD DSN=OUTPUT

    The JOB Statement

    Notes: Null Statement is a blank statement beginning with a double slash - // that marks the end of a job

    Each job must begin with a JOB statement. All statements that follow up to the next JOB statement, are parts of one job.

    The end of a job is marked by either another JOB statement or by a null statement.

    11

  • An EXEC statement often follow s the JOB statement. It names a program to be executed.Programs are stored in program libraries and retrieved by the operating system w hen they are referenced by an EXEC statement.

    Program Library

    //JOBNUM1 JOB 504,SMITH//STEP1 EXEC PGM=PROGRAMA//DD1 DD DSN=INPUT

    PROGRAMA

    INPUT

    The EXEC Statement

    Notes: A job contains one or more EXEC statements, each followed by statements that define one or more data sets needed for that job step.

    A job step ends with the next EXEC statement, the JOB statement for the next job, or a null statement.

    12

  • DD statements define the data sets the program uses during execution. Each data set used in the job requires at least one DD statement.

    The number of DD statements follow ing an EXEC statement depends on the number of data sets required by a program. The order of DD statements w ithin a job step is not usually signif icant.

    //JOBNUM1 JOB 504,SMITH//STEP1 EXEC PGM=PROGRAMA//DD1 DD DSN=OUTPUT//DD2 DD DSN=INOUT

    Data Sets

    The DD Statement

    Notes: By using a proper combination of options, DD statements may do the following:

    Give the data set name Specify the initial status and final disposition of the data set Specify volumes Specify record length, format, and blocking Request I/O devices Specify storage allocation for new data sets

    13

  • When deciding w hich programs to group together as a single job, you may consider programs that:

    Have to run sequentially Have the same job accounting informationAre dependent on each other

    INPUT

    INOUT1 00 1

    1 00 1

    1 00 1

    OUTPUT1 OUTPUT2

    Grouping Programs

    Notes: Consider two programs:

    Program A takes input from the INPUT data set and uses it to create the INOUT data set.

    Program B uses the data set created by Program A as its input and creates two more data sets called OUTPUT1 and OUTPUT2.

    Can you group Program A and Program B? Since these programs must run sequentially and Program B is dependent on Program A, they can be grouped into a single job.

    14

  • //JOBNUM1 JOB 504,SMITH//STEP1 EXEC PGM=PROGRAMA//DD1 DD DSN=INPUT,// DISP=SHR//DD2 DD DSN=INOUT,// DISP=(NEW,PASS)//STEP2 EXEC PGM=PROGRAMB//DD3 DD DSN=INOUT,// DISP=(OLD,CATLG)//DD4 DD DSN=OUTPUT1, // DISP=(NEW,CATLG,DELETE)//DD5 DD DSN=OUTPUT2,// DISP=(NEW,CATLG,DELETE)

    Grouping Programs: An Example

    Notes: In the example, an EXEC statement marks the beginning of the first job step (STEP1) and invokes a program called PROGRAMA.

    Because PROGRAMA uses one data set to create another, two data definition statements are needed. One for each of the following:

    INPUT

    INOUT

    When the system invokes PROGRAMB, another step begins in the job, which is STEP2.

    Because PROGRAMB uses the output of PROGRAMA as input and then creates two output data sets of its own, PROGRAMB needs three data definition statements, one for each of the following:

    INOUT

    OUTPUT1

    OUTPUT2

    15

  • Notes: Comment statements: You can use these to document JCL statements. A comment statement is coded with two forward slashes and an asterisk (//*) in the first 3 positions. The comment text is coded in positions 4 through 71.

    Null statements: You can use a null statement to mark the end of a job. It is coded with two forward slashes (//) in positions 1 and 2 and no other characteristics.

    16

  • JCL Statement Fields Most JCL statements have the same format consisting of f ive f ields: The identif ier f ield.

    The name field

    The operation f ield

    The parameter f ield

    The comment f ield

    // JOBNUM1 JOB 501,SMITH COMMENT

    Identifier

    Field

    Name

    Field

    Operation

    Field

    Parameter

    Field

    Comment

    Field

    1 2 3 71

    JCL Statement Fields

    Notes: The Identifier Field The identifier field occupies positions 1 and 2. It usually contains two forward slashes (//) and indicates that the statement is a JCL statement (as opposed to a data record).

    The remaining four fields must be coded from position 3 through position 71.

    The Name Field The name field must begin in position 3 with no spaces between the identifier and the name fields.

    The name field identifies the JCL statement by name so that other JCL statements or the operating system

    can refer to it.

    A name is optional for some EXEC statements, but is required on JOB and almost all DD statements.

    The Operation Field The operation field defines the JCL statement type - JOB, EXEC, or DD.

    For every JCL statement, the operation field must follow the name field and it must be preceded by at least one blank space.

    17

  • 18

    The Parameter Field The parameter field contains one or more parameters separated by commas. Each JOB, EXEC and DD statement has its own set of parameter information.

    The parameter field of each JCL statement must:

    Follow the operation field Include one or more blanks between it and the operation field Use commas to separate parameters Have no blanks between parameters

    The Comment Field A comment field contains extra documentation which you may choose to include. It contains documentation relating to the code or other messages from the programmer.

    A comment field must follow the parameter field and must be preceded by one or more blanks.

  • The specifications for JCL statement names are as follows:

    The name must begin in position 3 The name can be one to eight characters in length The first character in the name must be alphabetic character (A to Z) or national

    character (#, @, $). The first character cannot be numeric (0 through 9) The remaining characters can be alpha numeric (A to Z and 0 through 9) or national

    characters No special characters or spaces can be included in a name

    //JOB1 JOB 504,SMITH//STEP1 EXEC PGM=PROGRAMA//DD1 DD DSN=INPUT,DISP=SHR

    Name Field

    Rules for Naming JCL Statements

    Notes: Special characters:

    The following special characters can not be included:

    & (ampersand) ! (exclamation mark) (asterisk) , (comma) = (equal sign) - ( hyphen); .(period) + (plus sign) / (slash) ( (left parenthesis) ) (right parenthesis).

    19

  • You should remember the follow ing rules w hile w riting a JCL statement:

    The identifying characters (//) must be in positions 1 and 2. The name field must begin in posit ion 3. Each subsequent f ield must be preceded by one or more spaces. A continuation line begins w ith //. Continuing parameters must start in posit ions 4 through 16. Do not embed blanks w ithin any f ield. For example, do not code a blank to

    separate parameters in the parameter f ield. Do not code past position 71.

    Rules for Writing JCL Statements

    Notes: Apart from these rules, JCL coding is free form. Fields (except for the name field) and parameters do not have to begin or end in any particular position.

    20

  • In the JCL statements that you have seen so far, the operation fields contain the operators JOB, EXEC, and DD.

    Operation Fields: //JOB1 JOB 504,SMITH//STEP1 EXEC PGM=PROGRAM//DD1 DD DSN=INPUT,DISP=SHR

    Operation Field

    The JOB statement here contains parameters specifying the following: Accounting information (504) The JCL programmer's name (SMITH) MSGLEVEL (message level)

    parameter

    Parameter Fields: //JOB1 JOB 504,SMITH,// MSGLEVEL=(1,0)//STEP1 EXEC PGM=PROGRAM1,// TIME=4//DD1 DD DSN=INPUT,DISP=SHR

    Parameter Field

    Operation and Parameter Fields: An example

    Notes: Following are examples of three JCL statement

    types with different operators:

    The first statement is therefore, a JOB statement, which marks the beginning of a job. The second statement is therefore, an EXEC statement, which marks the beginning of a job step

    and specifies the program to be executed (PROGRAM1).

    The third statement is therefore, a DD statement, which identifies a data set that PROGRAM1 uses during processing.

    Parameter Fields: An Example

    The EXEC statement here contains two parameters:

    The first one specifies the program name (PROGRAM1). The second one specifies the maximum CPU time for the program (4 minutes)

    The DD statement here has two parameters:

    The first one specifies the data set name TRANS1

    The second one specifies a status of OLD.

    21

  • Following is an example of a single JCL statement that continues on 2 additional lines. All 3 lines comprise one JCL statement.

    //STEP1 EXEC PGM=PROGRAMA,// TIME=1,// PARM=LIST

    The following examples shows a JCL statement that contains: A comment INVENTORY JOB. A blank separates the parameter field

    from the words INVENTORY JOB A comment TEST. //* in the first 3 positions. The comment text is coded

    in positions 4 through 71.

    //JOB1 JOB 504,KAY INVENTORY JOB//* TEST

    Continuation and Comment statement: An Example

    Notes: You can continue a JCL statement on one or more separate lines.

    When can a JCL statement be continued on more than one line? A JCL statement may be continued on more than one line if:

    The JCL statement requires more than 71 positions to specify all the necessary parameters.

    You want to make it easier to read all the parameters. For example: You could code one parameter per line.

    In this example, note the following:

    The second and the third lines each have a blank in position 3, after the identifier field (//)

    The blank in position 3 of the second line, following the ending comma on the first line, indicates that the second line is a continuation of the first line

    The blank in position 3 of the third line, following the ending comma on the second line, indicates that the third line is a continuation of the second line

    22

  • 23

    Unit 2 Analyzing Job Output

    At the end of this unit, you will be able to:

    Describe the JCL statement listing that appear in an output listing

    Identify allocation messages that may appear in an output listing

    Identify termination messages that may appear in an output listing

    Identify error messages that may appear in an output listing

  • Use SDSF to view the output and determine w hether the job completed successfully.

    Action characters can be entered in the NP column:

    ?CSPSJ.

    SDSF

    Notes:

    DA Active users The Display Active Users (DA) panel allows authorized users to display information about jobs, users, started tasks, and initiators that are active on the system. It also shows system-wide data, such as CPU usage and paging rate.

    In a sysplex environment, the DA panel displays data for all systems in the sysplex. A sysplex-wide DA panel requires the use of RMF as the source of the data.

    Note: Some of the values on the DA panel, such as CPU% and SIO, are approximate. For detailed and precise performance monitoring, use RMF.

    I Input queue The Input Queue panel allows authorized users to display information about jobs that are on the JES2 input queue or that are executing.

    O Output queue The Output Queue panel allows authorized users to display information about output data sets for jobs, started tasks, and TSO users on any nonheld output queue.

    H Held output queue The Held Output Queue panel allows authorizedusers to display information about SYSOUT data sets for jobs, started tasks, and TSO users on any held JES2 output queue. There is one row for each output group for each job.

    ST Status of jobs

    24

    The Status panel allows authorized users to display information about jobs, started tasks, and TSO users on the JES2 queues.

  • 25

    Action characters Action characters that can be entered in the NP column by authorized users are: // Block repeat; type // on the first row and another // on the last row to be processed = Repeat previous action character or overtype + Expand the NP column. (Use RESET to reset.) ? Display a list of the data sets for a job. (Access the Job Data Set panel.) A Release a held job. C Cancel an active job or a job waiting to be processed CA Cancel a job that is defined to Automatic Restart Manager (ARM). CD Cancel a job and take a dump. CDA Cancel a job that is defined to ARM, and take a dump. D Display job information in the log. DL Display job information in the log, long form E Process a job again. EC Process a job again, but hold it prior to execution. H Hold a job. I Display job delay information. J Start a job immediately (WLM-managed classes only). L List a job's output status in the log. LL List a job's output status in the log, long form. O Release held output for printing. P Cancel a job and purge its output. PP Cancel a protected job and purge its output. Q Display output descriptors for all of the data sets for a job. (Access the Output Descriptors panel.) S Display the data sets for a job. (Access the Output Data Set panel.) SB Use ISPF Browse. SE Use ISPF Edit. SJ Use ISPF Edit to edit the JCL. W Cause job and message logs to spin . X Print output data sets. You can add the following: C Close the print file after printing (XC) D Display the Open Print Data Set panel (XD or XDC) F Display the Open Print File panel (XF or XFC) S Display the Open Print panel (XS or XSC)

  • OWNER Limit jobs displayed by ow ning user ID

    PREFIX Limit the jobs that are displayed by job name

    SET DISPLAY Controls the display of values

    PREFIX, OWNER and SET DISPLAY Commands

    Notes:

    PREFIX Command Purpose: Limit the jobs that are displayed by job name.

    Where used: Any SDSF panel (except help and tutorial), but affects only the DA, I, O, H, PS and ST panels.

    Format: PREFIX (string | * | ?)

    string is the name of the job, up to 8 characters, including* (any string of characters) or % (any single character). ?displays the current setting on the command line or pop-up. Examples: PREFIX IEB - Displays only jobs with the name IEB.

    PRE IEB* - Displays only jobs whose names begin with IEB.

    PREFIX with no parameters displays all jobs, except on the Held Output Queue panel, where it displays all jobs with names that begin with your user ID.

    26

  • 27

    OWNER Command Purpose: Limit jobs displayed by owning user ID. You must be authorized to use this command.

    Where used: Any SDSF panel (except help and tutorial panels) but only affects the DA, I, O, H, PS and ST panels.

    Format: OWNER (ownerid | *| ?) ownerid is the owning user ID of the job, or the netmail ID. It can be up to 8 characters including * (any string of characters) or % (any single character). ? displays the current setting on the command line or pop-up.

    Examples: OWNER KENJON2 (with no other filtering in effect). Displays only jobs for that owner.

    OWNER * (with no other filtering in effect). Displays all jobs for all owner IDs.

    SET DISPLAY Command: Purpose: Controls the display of values for PREFIX, DEST, OWNER, SORT, FILTER (tabular panels only) and SYSNAME.

    Where used: Any SDSF panel (except help and tutorial panels).

    Format: SET DISPLAY (ON | OFF | ?)

    ON displays the values just above the scrollable data. ONis the default. For SORT, the values are in the format column/order, or column//order if that column may degrade performance. For FILTER, the number of filters is shown.

    OFF ends the display of values. ? displays the current setting for SET DISPLAY.

    Example: SET DISPLAY ON Displays current values.

  • The Output Data Set panel allow s authorized users to brow se data, such as a job's output data sets

    Output Data Set panel

    Notes:

    The Output Data Set panel allows authorized users to browse data, such as a job's output data sets. It displays output formatted for a line-mode printer.

    Access it with the S action character.

    When used to browse a job's output data set, the panel also displays the JES2 job log, JCL for the job, and any job-related messages.

    28

  • JCL Statement Listing //

    JCL Statement Listing XX

    JCL Statements Listing: // and XX

    Notes:

    JCL Statement Listing // JCL statements coded as part of the job are preceded by slashes (//) in the identifier field.The JCL statements are numbered. When the SYSOUT data set is printed, the operating system numbers the JCL statements automatically.

    JCL Statement Listing - XX JCL statements can also be statements from any invoked procedure. The XX in the identifier field precedes invoked procedure statements

    Statements from the invoked procedures may also appear in the output listing. The first MSGLEVEL subparameter determines if these statements appear in the output listing.

    29

  • JCL statements, Allocation and Termination Messages

    Allocation and Termination Messages

    Notes: Allocation Messages Allocation messages show how the system assigns resources to a job.

    In an output listing, each of the allocation messages always follows a specially numbered statement called a system message identifier.

    Each allocation statement follows the system message identifier IEF237I.

    Termination Messages Termination messages show job termination and job step termination, as well as the disposition (or status) of the jobs data sets at the time of termination.

    In this example, the termination messages indicate the COMP step of the COB job terminated with a condition code of 12.

    At the time of termination, the system kept the VSCOB.LINKLIB data set, sent the JES2 control messages to the SYSOUT data set, and deleted the SYS86357.T103552.RA000.OL29EX00.R000001ystem data set.

    Like allocation messages, termination messages are characterized by specially numbered statements.

    30

  • JCL error messages point to any JCL statements that contain coding errors or f ail to execute properly.Usually JCL error messages contain the JCL statement number of the statement that caused the error to occur.The statement number of the statement that caused the error precedes the system message identif iers.

    17 IEFC612I PROCEDURE NOT FOUND18 IEFC630I UNIDENTIFIED KEYWORD ON THE EXEC STATEMENT19 IEFC629I

    //LA$TESTC JOB 31SP// COCHRAN,

    IEFC642I EXCESSIVE PARAMETER LENGTHIN THE MSGCLASS FIELD

    C03090156W,MSGCLASS=12

    INCORRECT USE OF APOSTROPHE IN THE DSNAME FIELD

    The MSGCLASS value is only one character

    Resulting error message

    JCL error messages : An Example

    Error Explanation

    Notes: Just like allocation and termination messages, system message identifiers precede JCL error messages.

    In the example, the value of the message class is too long (MSGCLASS=12).

    The value of the MSGCLASS parameter is only one character (e.g., MSGCLASS=A).

    31

  • Example 1

    //LA$TESTC JOB 31SPC03090156W,// COCHRAN,

    //LA$TESTC JOB 31SPC03090156W,// COCHRAN,MSGLEVEL=(1,1)

    32

    MSGLEVL=(1,1)

    IEFC630I UNIDENTIFIED KEYWORD MSGLEVL

    Resulting error message

    MSGLEVEL was misspelled

    MSGCLASS=A

    A blank space indicates that a comment follows

    Example 2

    //LA$TESTC JOB 31SPC03090156W,// COCHRAN,MSGLEVEL=(21)

    IEFC622I IMPROPER SUBPARAMETER LISTIN THE MSGLEVEL FIELD

    Missing comma

    Resulting error message

    Example 3

    JCL error messages : An Example

    Notes: Example 1:

    Here the MSGLEVEL parameter in the JOB statement is misspelled.

    The JCL error message would occur if the JOB statement was run.

    Example 2:

    In some cases, there might be errors in the JCL, even if no error messages appear in the output listing.

    Here in this example, a space exists between the MSGLEVEL and MSGCLASS parameters.

    The operating system considers anything after the space as comment and so will ignore the request for message class.

    And as MSGCLASS=A is considered a comment, no error message will be listed.

    Example 3:

    In the example, the comma between the 2 and 1 in the MSGLEVEL parameter was accidentally omitted.

    Running a job with this JOB statement would cause an JCL error message as shown.

  • 33

    Unit 3 Coding JOB Statements

    At the end of this unit, you will be able to:

    Explain the purpose and syntax of the JOB statement

    Define the JOB name

    Code positional parameters and keyword parameters

    Code the most commonly used keyword parameters on a JOB statement

    Complete the JOB statement

    Code additional JOB statement parameters

  • A JOB statement is the first statement in any JCL code and marks the start of a job and gives the name of the job. The parameters included in the JOB statement, such as accounting information and condition settings for job termination, apply to the entire job.

    The parameter field, in the JOB statement defines information that applies to the entire job. This information includes accounting information, programmer name, and additional information regarding the job.

    Parameter Fields

    //JOB1 JOB 776,M.FLURY

    JOB Name Operation Field

    Parameter Field

    JOB statement

    Notes: The JOB name is a 1 to 8 character name that identifies the job so that other JCL statements or the operating system can refer to it.

    The JOB name must begin in position 3 with no spaces between it and the identifier.

    The operation field follows the job name. For a JOB statement, the operator in the operation field is JOB.

    Parameter Fields

    One or more spaces separate the job parameters from the JOB operation field. The parameter field can specify job accounting information and the programmer's name as has

    been shown on the right.

    A comma separates the job accounting information and the programmer's name. Many organizations require the accounting information in order to charge computer time to the

    appropriate department.

    Often organizations require the programmer name information so that any problems return to the appropriate individual or group.

    34

  • To summarize, the rules require a job name to begin in position 3 and to be 1 to 8 characters in length.

    The first character of a job name should be either alphabetic or a national symbol. It should not be a number.

    The rest of the characters in the job name can be either alphanumeric or they can be national symbols.

    Special characters or spaces are not allowed.

    //JOB1 JOB//EXAMPLE4 JOB//RUN#2 JOB

    //JOB1+ JOB//EXAMPLE14 JOB// RUN#2 JOB

    Valid Job Names

    Invalid Job Names

    (Includes a special character)(More than eight characters)(Does not begin in position 3)

    JOB Name

    Notes: The job name is the second field in a JOB statement. It follows the identifier field (//).

    A JCL programmer should select the mandatory job name to identify the job to the operating system.

    The operating system will not run jobs having the same name concurrently. Therefore, it is important that each job should be assigned a unique name.

    If two jobs having the same name try to execute at the same time, the second one gets delayed till the first one completes.

    35

  • Positional parameters are parameters that are characterized by their location in the parameter field in relation to other parameters.

    The two positional parameters for a JOB statement are:

    Job accounting information Programmer name.

    For example: The job statement shown here uses a job accounting number of 776 and identifies the programmer of this job as K.YALE.

    //JOB1 JOB

    Positional parameters

    776,K.YALECLASS=A

    36

    //JOB2 JOB Positional Parameters

    Keyword Parameter

    Notes: There are two types of parameters:

    Positional parameters Keyword parameters

    What are positional parameters? Positional parameters are parameters that are characterized by their location in the parameter field in relation to other parameters.

    Positional parameters appear first in the parameter field in a fixed order if there are multiple parameters.

  • The value that you code for job accounting information depends on your installation. The code is usually a number to identify a department or person to whom processor time is bil led.

    //JOB1 JOB (255,DEPT/OPS),K.YALE

    Multiple Parameters

    If you omit the job accounting parameter, you must indicate its absence with a comma if you are coding the programmer name.

    Job Accounting Information

    //JOB1 JOB ,K.YALE

    Notes: When job accounting information consists of multiple subparameters, the job accounting subparameters must be enclosed in either parenthesis or apostrophes.

    What is an installation? Instalation refers to a particular computing system, including the work it does and the people who manage and operate it.

    In addition to the basic job accounting number, your installation may require information such as: Date

    Project director

    Project number

    The job accounting information appear in parentheses here because it appears in parentheses because it consists of two subparameters:

    255

    DEPT/OPS

    The parentheses indicate to the operating system that both subparameters comprise the job accounting information.

    Can you use special characters in subparameters? Special characters can be used in subparameters, provided the subparameters are enclosed in apostrophes.

    For example: The subparameter DEPT/OPS shown is enclosed in apostrophes because theslash (/) is a special character.

    37

  • The programmer name parameter identifies the person or group responsible for a job.If you decide to include this information, the programmer name must immediately follow the job accounting information parameter (or a comma to indicate its absence).

    255,SMITH,MSGLEVEL=(1,0)255,LONGPROGRAMERNAME255,JOHN SMITH255,OHARA

    Coding Programmer Name

    Notes: The rules that apply to a programmer's name are as follows:

    Separate the programmer's name from a preceding or following parameter by a comma

    Make sure the programmer's name does not exceed 20 characters

    Enclose the programmer's name in apostrophes when, the name contains special characters (other than periods or hyphens)

    Double any apostrophes in the programmer's name

    The programmer's name is not a mandatory part of the JOB statement unless your installation has made it so. Since the programmer name is the last positional parameter, you do not have to indicate its absence with a comma if you leave it out.

    38

  • Apart from positional parameters, the parameter may also contain keyword parameters.Keyword parameters are parameters consisting of a keyword and equal sign and variable information and supply information to the operating system for control of jobs. The commonly used keyword parameters are:

    MSGLEVEL MSGCLASS

    Keyword Parameters

    CLASSCONDGROUPMSGCLASSMSGLEVELCARDSNOTIFYPASSWORDPERFORMPRTYCCSID

    REGIONRDLINESRESTARTSECLABELTIMETYPRUNUSERBYTESPAGESSCHENV

    Defining Keyword Parameters

    Notes: The characteristics of keyword parameters include:

    They must follow any positional parameter

    They can be coded in any order

    They must include a keyword, an equal sign (=), and a value (for example, CLASS=A)

    There are a host of other keyword parameters which you can use in your JOB statement.

    You can use them to produce the exact results you want.

    Some of the most commonly used keyword Parameters:

    COND CLASS NOTIFY PRTY REGION TIME TYPRUN USER PASSWORD

    These parameters follow the same guidelines as the keyword parameters MSGLEVEL and MSGCLASS.

    39

  • The MSGLEVEL parameter controls how the JCL, allocation messages, and termination messages are printed in the job's output listing (SYSOUT).

    The MSGLEVEL parameter includes two subparameters: Statements and Messages. Syntax:

    MSGLEVEL=(statements,messages)

    //JOB1 JOB 255,SMITH,MSGLEVEL=(0,0)

    Statement

    MSGLEVEL Parameter

    Message

    Notes:

    You can request the following outputs using the MSGLEVEL parameter:

    A listing of the JOB statement only A listing of all user-supplied job control statements A listing of all user-supplied job control statements plus all inserted statements for procedures

    invoked by any of the job steps

    Allocation, disposition, and termination messages

    The MSGLEVEL Parameter Statement Subparameter

    The statement subparameter indicates which job control statements the system is to print on the job log.

    A statement subparameter can have one of the three values:

    0 Print only the JOB statement 1 Print all JCL statements and JES2 or JES3 control statements, including invoked procedure

    statements

    2 Print only JCL statements and JES2 and JES3 control statements from the job stream

    40

  • 41

    The MSGLEVEL Parameter Messages Subparameter

    The messages subparameter indicates which messages the system is to print on the job log.

    A messages subparameter can have one of the three values:

    0 Print only JCL messages. Print JES and operator messages only if the job terminates abnormally

    1 Print all allocation/termination messages

    Examples:

    //JOB2 JOB 255,SMITH,MSGLEVEL=(1,1)

    //JOB1 JOB 255,SMITH,MSGLEVEL=(0,0)

  • You can use the MSGCLASS keyword parameter to assign an output class for your output listing (SYSOUT). Output classes are defined by the installation to designate unit record devices, such as printers.

    Each class is one character long and is designated by:

    A letter (A-Z) or

    A numeral (0-9)

    //JOB1 JOB 255,MSGLEVEL=(1,1),//

    MSGCLASS Parameter

    MSGCLASS=A

    Notes: For example: In order to assign class A as the output class for your listing, you would code the MSGCLASS

    42

  • Both the MSGLEVEL and MSGCLASS parameters may have default settings, depending on your installation. Omitting one or both of the keyword parameters from the JOB statement, would make the operating system use these default settings.

    In this case, you would code these parameters only if you want to have a different message level or message class than the preset.

    //JOB1 JOB 255,MSGCLASS=A

    //JOB2 JOB 255,MSGLEVEL=(1,1)

    Default: MSGLEVEL=(1,1)

    Default: MSGCLASS=A

    Defaults for MSGLEVEL & MSGCLASS

    Notes: The MSGLEVEL subparameters are universal but output class assignments and the default settings for both parameters depend on your installation.

    43

  • //JOBNAME JOB ...,COND=(code,operator)//JOBNAME JOB ...,COND=((code,operator),(code,operator),... )

    The condition (COND) parameter specif ies the conditions under which a job terminates.

    A JCL programmer can specify many ways of how the COND parameter tests a return code. The operator subparameter specifies the comparison method.

    The Operator Subparameter

    GTGEEQNELTLE

    Operator MeaningGreater thanGreater than or equal toEqual toNot equal toLess thanLess than or equal to

    COND Parameter

    Notes: How does the COND parameter check for a condition? When a program terminates, it generates a return code that indicates the conditions under which the program terminated.

    The COND parameter that you code provides the "test" needed for the comparison by supplying a value withwhich to compare the return code.

    Each COND parameter uses the following two subparameters:

    Code Operator

    Code - This subparameter specifies a decimal value to be compared with the return code provided upon completion of a program. The decimal value can range from 0 to 4095.

    Operator - This subparameter specifies how the code subparameter is compared with the return code and specifies the type of text.

    You must remember to enclose each test in its own set of parentheses and the whole group of tests in another pair of parentheses, in order to test more than one return code. You do not have to add the second pairparentheses, if you want to test only one return code.

    You can include a maximum of eight different return code tests on each JOB statement.

    If any of the tests is true, the system bypasses all the remaining steps.

    44

  • 45

    What happens if you try to code more than eight comparisons? Attempting to code more than eight comparisons will result in you receiving a JCL error message and termination of the job abnormally. Therefore it is not possible to do so.

    You can include the COND parameter in either the EXEC statements or the JOB statements. COND

    parameters coded in the JOB statement are tested before any COND parameters coded in EXEC statements within the job. When coded in the EXEC statement, it is possible to test the return code of specific steps. In the JOB statement, tests apply to all steps in the JOB.

  • The job executes the remaining job steps only if the return code is 1 through 12. If the return code is 13 or higher, the remaining steps will be bypassed.

    //JOB1 JOB 776,SMITH,COND=(12,LT)//STEP1 EXEC PGM=PROGRAMA//STEP2 EXEC PGM=PROGRAMB

    Return Code Return Code < 16

    //JOB3 JOB 776,SMITH,// COND=((16,LT),(8,GT))//STEP1 EXEC PGM=PROGRAMA//STEP2 EXEC PGM=PROGRAMB

    COND Parameter: Examples

    Notes: Example 1(slide): This example helps you read the COND parameter in the JOB statement in the JOB statement as: "If 12 is less than the return code, do not execute any more job steps.

    Example 2 (slide): This example helps you to make multiple comparisons, which might be needed in some cases. Here you can read the COND parameters in the JOB statement as: "If 16 is less than the return code or if 8 is greater than the return code, do not execute any more job steps. The job executes subsequent job steps only if the return code is 8, 9, 10, 12, 13, 14, 15, or 16 for each previous job step.

    Example 3: //JOB2 JOB 776,SMITH,COND=(12,GT) //STEP1 EXEC PGM=PROGRAMA //STEP2 EXEC PGM=PROGRAMB This example helps you to read the COND parameter in the JOB statement as: "If 12 is greater than the return code of any job step, do not execute any more job steps."

    The job executes the remaining job steps only if the return code is 12 or greater. If the return code is 0 through 11, the remaining steps will be bypassed.

    46

  • A good balance of job class a ssignments helps to make the most efficient use possible of the system.

    Job class is a single character subparameter that can take the values A through Z or 0 through 9.

    The CL ASS Parameter Jobs are grouped into various job classes.

    //JOB1 JOB 504,SMITH,

    CLASS Parameter

    CLASS=A

    Job class

    Notes: Jobs are grouped into various job classes.

    Jobs are site-specific. You can check with your operations department about the job classes that are available for your use.

    Why are jobs grouped into classes? This is done for the following reasons:

    Job classes help to achieve a balance between different types of jobs

    They help avoid contention between jobs that use the same resources

    In order to specify a particular class for your job, you have to code the CLASS parameter on your JOB statement.

    Job class is a single character subparameter that can take the values A through Z or 0 through 9.

    47

  • The NOTIFY parameter indicates the TSO/E user the system must notify upon job completion. For example, to have the system send a message to JSMITH when the job EX completes, you would code the NOTIFY parameter on a JOB statement as:

    //EX JOB ...,NOTIFY=JSMITH

    NOTIFY Parameter

    Notes: If you use the NOTIFY parameter to specify your TSO/E user ID, the operating system automatically sends you a job completion message when your job ends.

    48

  • The PRTY parameter specifies a job's priority for selection within its job class. Usually, this parameter is meant to designate one job for execution over others in a class.The range of PRTY values is usually 0 through 15 for JES2 and 0 through 14 for JES3, with 0 having the lowest priority.

    //JOB1 JOB 504,SMITH,PRTY=3

    PRTY Parameter

    If you have to give a specific priority to a job within a specific class, you will code both the CLASS and the PRTY parameters on the JOB statement.

    //JOB1 J 4,SMITH,//

    PRTY Parameter

    OB 50 CLASS=T,PRTY=3

    Notes: When no priority has been specified, the system processes jobs within the same class in a first-in, first-out manner.

    Example: If you have to give a specific priority of 3 to a job (within its default class), you will code the PRTY parameter on a JOB statement as has been shown here

    49

  • The REGION parameter specifies the amount of storage space (in kilobytes or megabytes) that has to be allocated to a particular job.

    You can make use of this parameter to override the default region size set at your installation.

    //EXEC JOB ...,REGION=valueK//EXEC JOB ...,REGION=valueM

    Kilobytes Megabytes

    REGION Parameter

    Notes: Incase of a JOB statement, the region specified in the REGION parameter applies to all steps in a job and it overrides any REGION parameter coded on an EXEC statement.

    Normally, when the REGION parameter makes a GETMAIN request or a dynamic request for more storage, it limits the amount of virtual storage available to a program.

    Different programs operate best at different region levels. Fir instance, in order to limit the virtual storage space of a job to 512 KB, you will need to code the REGION parameter on the JOB statement as:

    //EX JOB ...,REGION=512K

    In a similar manner, in order to limit a job's virtual storage space to 1024 KB bytes or 1MB, you will need to code the REGION parameter as:

    //EX JOB ...,REGION=1M

    When you use the REGION parameter in conjunction with ADDRSPC=REAL, REGION specifies the amount of real storage.

    For instance, to limit a job's real storage space to 512 KB, you code the REGION parameter, along with the ADDRSPC parameter on the JOB statement as:

    //EX JOB ...,REGION=512K,

    // ADDRSPC=REAL

    50

  • The TIME parameter specif ies a maximum amount of processor time av ailable f or the job. If the limit in the

    TIME parameter is reached, the job will terminate abnormally. The syntax for the TIME parameter is:

    //jobname JOB ...,TIME=(minutes,seconds)

    The TIME parameter preserves processor time in case of an undetected error (like an endless loop) that may

    surface only during execution of program.

    Examples

    //EXAMPLE1 JOB 776,STUDENT,TIME=(2,45)//EXAMPLE2 JOB 776,STUDENT,TIME=1440//EXAMPLE3 JOB 776,STUDENT,TIME=NOLIMIT//EXAMPLE4 JOB 776,STUDENT,TIME=MAXIMUM

    Limit the CPU execution time to 2 minutes and 45 seconds

    TIME Parameter

    Notes: For example, to limit the CPU execution time to 2 minutes and 45 seconds, you will need to code the TIME parameter on a JOB statement as:

    //EXAMPLE1 JOB 776,STUDENT,TIME=(2,45)

    TIME Subparameters:

    The 1440 indicates that a job is allowed to run for an unlimited amount of time. Literally, the subparameter 1440 means 1,440 minutes (i.e. 24 hours). However, the 1440 subparameter has special meaning to the operating system.

    For instance, in order to allow your job to run indefinitely, you will code a JOB statement using the NOLIMIT subparameter as:

    //EXAMPLE JOB 776,STUDENT,TIME=1440

    The NOLIMIT subparameter is identical in function to the 1440 subparameter.

    Coding NOLIMIT with the TIME parameter will lead to the associated job running for an unlimited amount of time.

    For instance, in order to allow a job to run indefinitely, you will have to code a JOB statement using the NOLIMIT subparameter as:

    //EXAMPLE JOB 776,STUDENT,TIME=NOLIMIT

    The MAXIMUM subparameter indicates that the associated job can run for 357,912 minutes, which is the maximum time the operating systems allows for a job (other than unlimited).

    For example to limit the jobs CPU processing time to 357,912 minutes, you would the code a JOB statement as:

    //EXAMPLE JOB 776,STUDENT,TIME=MAXIMUM

    51

  • The TYPRUN parameter identifies jobs that have special processing requirements. The subparameters that can be used with the TYPRUN key word are as f ollows:

    COPY (for JES2 only) - This is used to tell the system to copy the input to a SYSOUT data set for output processing, but not to execute it.

    HOLD - this is used to tell the system to hold the job prior to execution, until the operator releases the job.

    SCAN - This is used to tell the tell the system to scan the JCL for syntax errors, but not to execute it.

    TYPRUN Parameter

    Notes:

    52

  • The USER parameter identif ies the user ID of the person who submitted the job. This parameter uses a USERID subparameter which must be 1 to 7 alphanumeric characters or nationalsymbols. The f irst character cannot be numeric.

    The PASSWORD parameter identifies a current RACF password for a job.The PASSWORD parameter uses a job-specif ic subparameter, which can be 1 to 8 alphanumeric characters or national symbols.

    To specify a password of XYZ123, with a user ID of HARRIS, you would code the PASSWORD and USER parameters as shown here.

    //EXAMPLE JOB 776,STUDENT,PASSWORD=XYZ123,USER=HARRIS

    USER and PASSWORD Parameters

    Notes: In most cases, the USER parameter is used in conjunction with the PASSWORD parameter.

    Many system facilities, including the Resource Access Control Facility (RACF) and the System Resource

    Manager (SRM) use the USERID subparameter.

    Just as in the case of the USER parameter, the PASSWORD parameter may or may not be required at your site.

    53

  • You can code multiple keyword parameters on a single JOB statement in any order that you choose after any positional parameters are coded.

    //JOB1 JOB 504,SMITH,// TIME=(2,45),// REGION=768K,CLASS=T,// PRTY=3,// NOTIFY=JSMITH

    Coding Multiple Keyword Parameters

    Notes: Here, the JOB1 job is limited in processing time to 2 minutes, 45 seconds, and has been allocated a limited space of 768 KB.

    This job has a class of T, and a job priority of 3 within class T. This means that this job named JOB1 will run ahead of all other jobs in class T that have a lower priority value (PRTY value) than 3.

    The operating system notifies user JSMITH, upon the complete execution of the job.

    54

  • 55

    Unit 4 Coding EXEC Statements

    At the end of this unit, you will be able to:

    Code an EXEC statement to specify a program to be executed

    Correct coding errors in an EXEC statement

    Identify which JCL statement has caused a PROGRAM NOT FOUND error message

    Identify the system library from which programs are retrieved at execution time

    Identify the DD statement names used to specify a private library from which programs are retrieved at execution time

    Select the place in the job stream where STEPLIB and JOBLIB DD statements should be located

    Code a JOBLIB DD statement

  • Notes: The EXEC statement has to be coded using a particular JCL syntax. Like the JOB statement, the EXEC statement too has five fields. The EXEC statement format includes the following:

    Identifier Field (//): It occupies position 1 and 2

    Name Field: It names the step starting in position 3

    EXEC Operator Field: It states the JCL statement type

    Parameter Field: It is used to state the parameters used on an EXEC statement

    Comment Field: This field is optional

    56

  • It is important for y ou to always follow the JCL step name coding rules while naming a step. Not doing so will lead to JCL errors.

    Following are the coding rules f or the step name:

    The step name must begin in position 3

    The step name must be 1 to 8 characters in length

    The f irst character in the step name should be either alphabetic or a national symbol

    The f irst character cannot be a number

    Rest of the characters in the step name can either be alphanumeric or they can be national symbols

    Special characters and spaces cannot be used in a step name

    //STEP1 EXEC//EXAMPLE4 EXEC//RUN#2 EXEC

    //STEP1+ EXEC//EXAMPLE14 EXEC// RUN#2 EXEC

    Valid Step Names

    Invalid Step Names

    (Includes a special character)(More than eight characters)(Does not begin in position 3)

    Step Name

    Notes: Examples:

    The step name LA$JOE is acceptable because it fits all the requirements defined in the rules for coding a step name( the $ is one of the national symbols).

    However, STEP#FOUR is not a valid step name because it contains more than eight characters.

    57

  • The parameter field follows the EXEC operator and may contain multiple parameters. The first parameter in an EXEC statement is a positional parameter that designates the program or procedure the system executes during the jobstep.

    This positional parameter is often coded like a key word parameter using either PGM= or PROC=.PGM= designates a program the system executes during the job step. PROC= designates a procedure the system executes.

    If you omit the PGM= or PROC= key word, the operating system automatically looks f or a procedure by the specif ied name

    //STEP1 EXEC procedure-name//STEP2 EXEC PROC=procedure//STEP1 EXEC PGM=program-name

    Positional Parameter

    Positional Parameter

    Notes: PGM= designates a program the system executes during the job step. Shown here is the syntax of PGM as a positional parameter in the EXEC statement.

    PROC= designates a procedure the system executes. The syntax of PROC as a positional parameter in an EXEC statement.

    If you omit the PGM= or PROC= keyword, the operating system automatically looks for a procedure by the specified name

    58

  • In the example shown here, the equal sign in the parameter field is preceded and followed by a space. The system interprets "PGM" as a procedure name and not as a keyword f or the positional parameter of the EXEC statement. When this program executes, an error "NOT FOUND" may appear. You can fix this error by eliminating the spaces bef ore and after the equal sign.

    //LA$JOE JOB 3SPO3W,CLASS=B//STEP1 EXEC PGM = IEFBR14

    SYSTEM ABEND

    Positional Parameter Coding Errors

    Notes: JCL errors occur if you, as a JCL programmer fail to follow any of the coding rules regarding the PGM and PROC positional parameters.

    For example, the misspelling of PGM (as PGR) in the EXEC statemen returns a JCL error.

    59

  • You may code key word parameters on the EXEC statement in any order, following the program or procedure name being executed.

    The two keyword parameters used most frequently with the EXEC statement are: The PARM parameter The COND parameter

    PGM=PROGA,

    Keyword Parameters

    ACCTRDDYNAMNBRADDRSPCPERFORMREGIONPARMCONDTIMEDPRTYCCSID

    keyword

    Notes: You can use any of the keyword parameters shown here on the EXEC statement.

    If you code one of these keyword parameters on the EXEC statement, the keyword parameter value will apply only to that step.

    60

  • The PARM parameter passes information to the executing program. Some programs accept inf ormation fromthe PARM parameter about how many times to execute.

    The syntax for the PARM parameter is: PARM=(SUBPARAMETER,SUBPARAMETER)

    //JOB1 JOB 766,SMITH//RUN#2 EXEC PGM=REPORT,// PARM=MONTHLY

    //JOB1 JOB 766,SMITH//RUN#2 EXEC PGM=REPORT,// PARM=10-31-98

    //JOB1 JOB 766,SMITH//RUN#2 EXEC PGM=REPORT,// PARM=(MONTHLY,10-31-98)

    Examples

    PARM Parameter

    Notes: The PARM parameter passes information to the executing program. Some programs accept information from the PARM parameter about how many times to execute.

    For example, a program may need to know whether a report cycle is "annual" or "monthly".

    The records the program uses vary depending on which value is passed to it.

    Similarly, the PARM parameter can supply a password to the program that is required before the program executes.

    Rules for Coding the PARM Parameter

    The general syntax and rules for coding the PARM parameter are:

    The PARM parameter can include up to 100 characters The PARM parameter can consist of several subvalues separated by commas. Subparameters must be enclosed in parentheses or apostrophes Special characters must be enclosed in apostrophes

    Example 1 (slide):

    This EXEC statement passes one value (MONTHLY) as input to a program named REPORT.

    61

  • 62

    Example 2 (slide):

    This EXEC statement passes the date (10-31-98) as input to the program called REPORT. The subparameter is enclosed in apostrophes because special characters are used.

    Example 3 (slide):

    In this example, the EXEC statement passes both the type of report (MONTHLY) and the date (10-31-98) as subparameters of the PARM parameter. The two subparameters are enclosed in parentheses.

  • To provide control over the whole job, you can code the condition (COND) parameter on the JOB statement.The syntax for the COND is: COND=(code,operator[,stepname][.procstepname])

    When you use the COND parameter on an EXEC statement, the parameter specifies the conditionsthat allow the system to by pass a step by testing return codes f rom any or all previous steps. If the result of any test is true, the system will bypass the step.

    COND Parameter OperatorsLike the JOB statement COND parameter, each test in an EXEC statement COND parameter has its own operator. This operator is independent of any other operators in any other tests.

    GTGEEQNELTLE

    Greater thanGreater than or equal toEqual toNot equal toLess thanLess than or equal to

    COND Parameter

    Notes: As on the JOB statement, the code subparameter indicates a return code, and the operator subparameter indicates the type of test used for the comparison.

    What happens if you specify only the code and operator subparameters? If you specify only the code and operator subparameters, the test runs for all previous return codes in the job.

    The stepname.procstepname subparameter (instead of the stepname subparameter) compares a code value against the return code from a specific previous procedure job step.

    The actual return code value, which may range from 0 to 4095, is compared with the return code specified in the COND parameter.

    You can code up to eight comparisons. If any comparison is true, the system bypasses the step.

    63

  • In the example shown here, the COND parameter reads as follows:"If the return code f rom any prev ious step is less than 8, then by pass this step."

    //JOB1 JOB 778,SMITH//EXAMPLE2 EXEC PGM=DELETE//EXAMPLE3 EXEC PGM=UPDATE,// COND=(8,GT)//DD1 DD DSN=INPUT

    //JOB1 JOB 778,SMITH//EXAMPLE2 EXEC PGM=DELETE//EXAMPLE3 EXEC PGM=UPDATE,// COND=(8,GT,EXAMPLE2)//DD1 DD DSN=INPUT

    The COND parameter in the step EXAMPLE3, includes a stepnamesubparameter. This causes the COND statement to read as follows:

    "If the return code f rom step EXAMPLE2 is less than 8, then bypass step EXAMPLE3."

    COND Parameter Examples

    Notes:

    64

  • //JOB1 JOB 778,SMITH//EXAMPLE1 EXEC PGM=STEP1//EXAMPLE2 EXEC PGM=STEP2//EXAMPLE3 EXEC PGM=STEP4, COND=EVEN

    Program STEP3 always executes, even if a previous step (e.g. STEP2) in the job terminates abnormally.

    //JOB1 JOB 778,SMITH//EXAMPLE1 EXEC PGM=STEP1//EXAMPLE2 EXEC PGM=STEP2//EXAMPLE3 EXEC PGM=STEP3, COND=ONLY

    Program STEP3 will execute only if a previous step in the job terminates abnormally.

    The EVEN subparameter allows the current step to execute even if any prev ious step terminates abnormally.

    Conversely, the ONLY subparameter allows the current step to execute only if any previous step terminatesabnormally.

    The COND Subparameters EVEN & ONLY

    Notes: In addition to code, operator, stepname, and procedure stepname, the EVEN and ONLY subparameters may also be coded on the COND parameter.

    These subparameters do not apply to condition codes returned by a program after normal termination. They relate to abnormal termination of a prior step. Abnormal termination occurs when unexpected conditions arise during execution of a step.

    Without the use of EVEN or ONLY, a job bypasses all remaining steps following an abnormal program termination.

    The EVEN and ONLY subparameters cannot appear on the same step. They are mutually exclusive.

    However, EVEN or ONLY can be coded in place of one of the eight return code test allowed for each step. The order in which tests are coded does not matter.

    Example EVEN:

    //JOB1 JOB 778,SMITH

    //EXAMPLE1 EXEC PGM=STEP1

    //EXAMPLE2 EXEC PGM=STEP2

    //EXAMPLE3 EXEC PGM=STEP3

    //EXAMPLE4 EXEC PGM=STEP4,

    If you code COND=EVEN on an EXEC statement as shown here, the program STEP4 always executes, even if a previous step (e.g. STEP3) in the job terminates abnormally.

    65

  • 66

    Example ONLY:

    //JOB1 JOB 778,SMITH

    //EXAMPLE1 EXEC PGM=STEP1

    //EXAMPLE2 EXEC PGM=STEP2

    //EXAMPLE3 EXEC PGM=STEP3

    //EXAMPLE4 EXEC PGM=STEP4,

    // COND=ONLY

    //DD1 DD DSN=INPUT

    If you code COND=ONLY on an EXEC statement as shown here, the program STEP4 will execute only if a previous step in the job terminates abnormally.

  • //RUN31 JOB 777,CLASS=B//STEPA EXEC PGM=REPORTCSV003I REQUESTED MODULE REPART NOT FOUNDCSV028I JOBNAME=RUN31 STEPNAME=STEPA

    Error Message

    In a job, each job step beings with an EXEC statement that identifies a program name. In order to run the program in the EXEC statement, the system searches for it in program libraries.In the example, the programmer wanted to execute a program called REPORT and coded the JCL as shown.

    The operating system searches SYS1.LINKLIB or LINKLIST f or REPART. The error messages shown occur because REPORT was misspelled as REPART in the JCL

    Program Libraries

    Notes: In the example, the programmer wanted to execute a program called REPORT and coded the JCL as shown.

    The operating system searches SYS1.LINKLIB or LINKLIST for REPART. The error messages shown occur because REPORT was misspelled as REPART in the JCL

    In a job, each job step beings with an EXEC statement that identifies a program name. In order to run the program in the EXEC statement, the system searches for it in program libraries.

    It will search one or more system program libraries automatically or you can direct the system to search for the program in a private program library.

    The operating system searches SYS1.LINKLIB or LINKLIST for REPART. The error messages shown occur because REPORT was misspelled as REPART in the JCL

    67

  • You can use private libraries to store programs.The JOBLIB DD statement causes the system to search a private library for all programs bef ore searching SYS1.LINKLIB.

    //JOB1 JOB 776,SMITH//JOBLIB DD DSN=LIBRARY,DISP=SHR//STEP1 EXEC PGM=MYPROG1//STEP1 EXEC PGM=MYPROG2

    The STEPLIB DD statement makes more sense to direct the system to search a private library on a step-by-step basis. //STEP1 EXEC PGM=PROGA

    //STEPLIB DD DSN=MYLIB,DISP=SHR//*//STEP2 EXEC PGM=PROGB//STEPLIB DD DSN=MYLIB,DISP=SHR

    If a STEPLIB and JOBLIB DD statement both appear in a job, the system ignores JOBLIB

    Private Program Libraries

    Notes: You can use private libraries to store programs.

    If you want to invoke a program called MYPROGwhich is stored in a private library, you must tell the operating system the name of the privatelibrary by coding a special DD statement named JOBLIB.

    If you want the system to call a program from a private library you should insert the JOBLIB DD statement in the job before the first EXECstatement in the job.

    The JOBLIB DD statement causes the system to search a private library before searching SYS1.LINKLIB.

    If the system does not find the program in the library specified by the JOBLIB DD statement then it goes on to search the SYS1.LINKLIB and the libraries defined in LINKLIST next. This search sequence repeats for every step in the job.

    The STEPLIB DD statement can be placed anywhere in a job step but it typically appears after an EXEC statement.

    If most of the programs for a job reside in SYS1.LINKLIB or LINKLIST and only a few are in private libraries, it makes more sense to direct the system to search a private library on a step-by-step basis.

    This saves processing time by eliminating unnecessary searching.

    To search a private library directly you use a special DD statement called STEPLIB DD statement as shown.

    What if a STEPLIB and JOBLIB DD statement both appear in a job? In this case the STEPLIB DD statement overrides the JOBLIB statement. The system ignores JOBLIB and it does not search it in the step. It starts search only with the step library.

    68

  • 69

    Example: //JOB1 JOB 777,SMITH

    //JOBLIB DD DSN=USER1

    //STEP1 EXEC PGM=MYPROG

    //STEPLIB DD DSN=LIBRARY,

    // DISP=SHR

    Just like a JOBLIB DD statement, the STEPLIB DD statement searches a private library for a specified program, but the STEPLIB DD statement is in effect only for the duration of the step it follows.

    If the system does not find the program in library specified by the STEPLIB DD statement, it searches the system libraries (SYS1LINKLIB and LINKLIST) next.

    If it does not find the program there, the job step terminates abnormally.

    Example:

    //JOB1 JOB 777,SMITH

    //STEP1 EXEC PGM=PROGA

    //STEP2 EXEC PGM=MYPROG

    //STEPLIB DD DSN=LIBRARY,

    // DISP=SHR

    //STEP3 EXEC PGM=PROGB

    When executing STEP1, the system will search in SYS1.LINKLIB and LINKLIST for PROGA.

    But when executing STEP2, the system will look first in the private library named LIBRARY for MYPROG, ignoring SYS1.LINKLIB and LINKLIST. If it does not find MYPROG in LIBRARY it will search in SYS1.LINKLIB and LINKLIST.

    And in STEP3 the system will look for PROGB in SYS1.LINKLIB and LINKLIST but not in LIBRARY.

  • 70

    Unit 5 Coding DD Statements

    At the end of this unit, you will be able to:

    Identify how to connect a DD statement to the program requirement for input/output

    Identify the number of DD statements required for a given program

    Understand the advantages of identifying the application data set and its location at program initiation time

    Use backward reference feature with the PGM, DSN, VOL, and DCB parameters

    Code statements to concatenate data sets and create dummy data sets

    Code statements to produce storage dumps

  • Each data set used or created in a job step requires a separate DD statement.

    The syntax used f or coding a DD statement in the JCL is:

    //ddname DD parameter(s)

    The DD statement identifies the basic information about a data set including:

    DDNAME used by the program to reference a data set

    The data set name

    The location of the data set

    The manner in which data set should be accessedExemple:

    //MYJOB JOB//STEP1 EXEC PGM=PAYROLL

    //PAY DD DSN=WEEKPAY1

    DD statement

    Notes: The advantages of using DD statements in JCL are:

    It allows the data set information to change without recompiling the programs that access the data set It increases reusability of programs

    The installation becomes more adaptable

    Example:

    The PAYROLL program might specify a DDNAME of PAY for the weekly payroll data set. The program uses DDNAME PAY to point to the data set for input to the payroll program.

    If the payroll data set for that week is WEEKPAY1, then the JCL might appear as

    //MYJOB JOB

    //STEP1 EXEC PGM=PAYROLL

    //PAY DD DSN=WEEKPAY1

    71

  • Using DDNAME in Programs

    How do we code DDNAME in programs?

    The f ormat for coding a DDNAME in a program depends on the language in which the program is written.

    The way the DDNAME is coded is different in COBOL, PL/1, and Assembler. In the example theDDNAME used is DD1.

    COBOL

    SELECT FILEIN ASSIGN TO DD1

    READ FILE(DD1)

    FILEIN DCB DDNAME=DD1,...

    72

    PL/1

    Assembler

    //MYJOB JOB//STEP1 EXEC PGM=PAYROLL//DD1 DD DSN=WEEKPAY1

    Notes: The ASSIGN clause in the Environment Division of the COBOL program identifies the DDNAME that must be used in the DD statement.

  • The characteristics of DD Statement Parameters are:

    Adding parameters in the DD statement allows us to specify the characteristics of a data set

    DD statement parameters can be coded in any order as they are key word parameters

    //DDNAME DD parameter(s)

    DSNDISPUNITVOLSPACELABELDCBSYSOUT

    DD Statement Parameters

    Notes:

    73

  • The Data Set Name (DSN) specifies the name of the data set

    Temporary data set

    It is used f or storage within the life cycle of the job. Syntax:

    //DATA1 DD DSN=&&FIRSTor

    //DATA1 DD (all needed parameters except DSN parameter)

    Non-Temporary Data Set

    It can be saved and reused after the job has completed. Non-temporary data sets must be giv en a data set name. Sy ntax:

    //DATA2 DD DSN=SECOND

    DD Statement Parameters - DSN

    Notes: Temporary Data Sets The characteristics of a temporary data set are: Temporary data set is used for storage within the life cycle of the job Naming a temporary data set is optional Temporary data set names can be coded either by including two ampersands (&&) before the

    name or by leaving out the DSN parameter

    The syntax used in coding temporary data sets is:

    //DATA1 DD DSN=&&FIRST or

    //DATA1 DD (all needed parameters except DSN parameter)

    When the DSN parameter is omitted the system assigns a unique name.

    Non-Temporary Data Sets The characteristics of non-temporary data sets are: Non-Temporary Data Sets Non-temporary data sets can be saved and reused after the job has completed Non-temporary data sets must be given a data set name

    The syntax used in coding non-temporary data sets is:

    //DATA2 DD DSN=SECOND

    74

  • The data set disposition parameter (DISP) specifies the current status of a data set and tells the system which method to use for handling the data set after the job step terminates.

    The current status of a data set can be:

    Old (OLD) New (NEW)

    Shared (SHR)

    The method of handling a data set after termination can be:

    Delete (DELETE)

    Keep (KEEP) Catlog (CATLG)

    Uncatlog (UNCATLG)

    Pass (PASS)

    //DATA1 DD DSN=FIRST,// DISP=(NEW,CATLG)//DATA2 DD DSN=SECOND,// DISP=OLD//DATA3 DD DSN=AAAAA,// DISP=(,CATLG,DELETE)//DATA4 DD DSN=BBBBB,// DISP=(OLD,DELETE,DELETE)//DATA5 DD DSN=CCCCC,// DISP=(,PASS)

    DISP=([status][,normal-termination-disp] [,abnormal-termination-disp])

    Examples

    DD Statement Parameters - DISP

    Notes: For example, the DISP parameter can tell the system to delete a temporary data set at the end of a job or save a non-temporary data set. The DISP statement can also setup a data set to be shared or passed to another job, cataloged in a library, or used to create a new data set.

    75

  • The I/O UNIT parameter is used to request the type (or group) of hardware device(s) used to store or access a data set.

    //DATA2 DD UNIT=3390

    //DATA2 DD UNIT=SYSDADevice

    Group

    DD Statement Parameters - UNIT

    Notes: Using the UNIT parameter, you can specify a particular tape drive, printer, or DASD device based on its hardware address, device type or group name.

    Interaction with I/O devices can be accomplished by specifying its:

    Hardware address

    Device type

    Group name

    76

  • The Volume (VOL) parameter is used to indicate the specif ic media volume a tape data set has to access.

    A media v olume might be a specific tape volume named ACCT01 or specif ic disk pack named TSO001.

    //INPUT DD DSN=MYTAPE,// UNIT=TAPE,// VOL=SER=ACT001//INPUT DD DSN=ABC,// UNIT=DISK,// VOL=SER=TSO001

    DD Statement Parameters - VOL

    Notes: A media on a storage device such as a tape reel or a Direct Access Storage Device (Disk unit) is called a volume.

    77

  • By using the SPACE parameter the required amount of space for a data set can be allocated.

    //DATA1 DD DSN=FIRST,// DISP=(NEW,CATLG),// UNIT=SYSDA,// SPACE=(TRK,(10,20),RLSE)

    SPA CE= ({TRK,}(primary-qty[,second-qty][,directory])[,RLSE]){CYL,}

    DD Statement Parameters - SPACE

    Notes: The characteristics of the SPACE parameter are:

    Coding the SPACE specifies how much room on a DASD volume the system should allocate to the new data set

    The space can be reserved by specifying a number of blocks, tracks or cylinders

    78

  • What are the characteristics of the DCB parameter?

    The Data Control Block (DCB) parameter is used during execution to complete inf ormation in theprogram's data control block for a data set.

    The DCB parameter identif ies the ty pe, block size, and length of records in a data set: LRECL=bytes Used to specify the size of the registers for a new data set.

    BLKSIZE=bytes Used to specify the maximum size of a block in bytes.

    RECFM = parameter Used to specify the format and the characteristics in the new data set. DSORG=organization Specifies the organisation f or a data set

    //DATA1 DD DCB=(RECFM=FB,// LRECL=80,BLKSIZE=6400)//DATA2 DD RECFM=FB,DSORG=PO,// LRECL=80,BLKSIZE=6400)

    DD Statement Parameters - DCB

    Notes: RECFM = parameter Used to specify the format and the characteristics in the new data set.

    F fixed size

    FB blocked fixed size

    V variable size

    VB blocked variable size

    DSORG=organization Specifies the organisation for a data set

    PS Physical sequential

    PO Partitioned data set

    79

  • The output stream, or SYSOUT data set, is the data set that contains the results of a job to beprinted.

    The SYSOUT parameter specif ies a system output data set and its output class.

    The DD statement routes the output to a printer of the specified output class.

    The output class can be any alphanumeric character (A-Z, 0-9) or an asterisk.

    //DATA1 DD SYSOUT=A

    DD Statement Parameters - SYSOUT

    Notes: The output class in an installation can be used for printing on special forms or for high-volume and high-priority output.

    The asterisk tells the system to use the same class as the MSGCLASS parameter in the JOB statement.

    80

  • What is a dummy data set?

    How does it work?

    A dummy data set is a data set for which all Input or Output (I/O) operations are bypassed.A special DD statement, DD DUMMY, is used to ignore a data set during the execution of a program.

    When a data set is assigned dummy status, all I/O operations are by passed and device allocation, space allocation and data set disposition are ignored.

    Dummy data sets can be specif ied in DD statements by doing one of the following:

    Coding DUMMY as the first DD parameter

    //ddname DD DUMMY

    Coding DSN=NULLFILE

    //ddname DD DSN=NULLFILE

    Dummy Data Sets

    Notes: Each data set that is referred by a program should have a ddname. The JCL for the program must contain the corresponding DD statements.

    If a data set is not coded by a DD statement, then the program will abnormally end (ABEND) as shown.

    When an input data set is optional for the programs processing or when an output data set is not required dummy data sets can be used.

    81

  • A programmer can code DD statements to request that sev eral data sets be concatenated.Data set concatenation enables the system to process several separate physical data sets as one logical data set.

    Following steps are inv olved in concatenating data sets:

    1) Code a standard DD statement for the f irst data set only

    2) Add a DD statement without a ddname for each data set to be concatenated

    3) Sequence the statements in the order they are to be processed

    //ddname DD DSN=JAN.DATA// DD DSN=FEB.DATA// DD DSN=MAR.DATA

    Data Set Concatenation

    Notes: Consider a cost ledger system to produce a monthly cost summary file. At the year end, it is required to process all 12 monthly data sets to produce an annual report. All the data sets are concatenated so that they can be processed sequentially.

    In this example, the program uses a ddname of LEDGER and the monthly data sets are named JAN, FEB, MAR and so on.

    The operating system draws the concatenated data sets sequentially, treating them as a single logical data set.

    How concatenation is useful? Using concatenation, a program can be run with one or several input data sets by merely changing the DD statement.

    While concatenating data sets the following points must be considered:

    The concatenated data sets must have the same (or compatible) DCB subparameters. Namely,

    RECFM, LRECL and BLKSIZE.

    A maximum of 255 sequential and 16 partitioned data sets can be concatenated.

    82

  • It is a technique that directs the system to copy parameter values from preceding DD statements. Syntax:

    Keyword = *. [stepname] [procstep] ddnameDSN Backward ReferenceIt is a coding technique that refers to a prior DD statement that names the data set you want to process.

    DCB Backward ReferenceIt is a coding technique that allows y ou to copy a list of attributes from a prior DD statement in the same or prev ious job step.

    //STEP1 EXEC PGM=PROG1//DD1 DD DISP=(NEW,PASS),DSN=WEEK1 //STEP2 EXEC PGM=PROG2//DD2 DD DSN=*.STEP1.DD1,DISP=OLD

    //STEP1 EXEC PGM=PROG1//DD1 DD DCB=(RECFM=FB,ZRECL=80,BLKSIZE=800)//STEP2 EXEC PGM=PROG2 //DD2 DD DCB=*STEP1.DD1,...

    Using Backward Reference

    Notes: Four common backward references are:

    PGM Reference: Points to a previous data set to specify a program name DSN Reference: Points to a previous data set name VOL Reference: Points to a previous volume serial number DCB Reference: Points to DCB attributes defined in another previous DD statement

    PGM Backward Reference: A PGM backward reference is useful in a program development environment, in which the output from one job step (typically a linkage edit step) may become the program to execute in a subsequent step. In such a case, instead of naming the program, you can code a PGM backward reference.

    A PGM backward reference is a coding technique that points to a prior DD statement which specifies a member of a program library.

    The general form of a PGM backward reference is as follows:

    //STEP EXEC PGM=*.stepname.ddname

    83

  • 84

    Example:

    //LKED EXEC PGM=LINKEDIT

    //SYSLMOD DD DSN=&&GOSET(GO),

    // DISP=(NEW,PASS)

    //STEPA EXEC PGM=*.LKED.SYSLMOD

    The ddname is SYSLMOD and the data name is &&GOSET(GO).

    The DISP parameter specifies that the data is NEW and is to be PASSed to another step.

    TEPA executes the program, using a PGM backward reference.

    DSN Backward Reference: This technique is useful when coding jobs that consist of several steps, with multiple references to the same data set. The reference can also be used to retrieve temporary data sets in subsequent job steps, without knowing the name.

    The DSN backward reference is a coding technique that refers to a prior DD statement that names the data set you want to process.

    The general form for the DSN backward reference is as follows:

    DSN=*.stepname.ddname

    Example:

    //STEP1 EXEC PGM=PROG1

    //DD1 DD SPACE=(TRK0,(200,20,2)),

    // DISP=(NEW,PASS),DSN=WEEK1

    //STEP2 EXEC PGM=PROG2

    //DD2 DD DSN=*.STEP1.DD1,DISP=OLD

    Consider a payroll job consisting of several steps, all referring to the same data set. The job needs to be executed each week using a data set that contains the weeks transactions.

    This requires that, each week the data set name must be changed in the order WEEK1, WEEK2 and so on.

    By using a DSN backward reference, the data set can be retrieved each week by changing only one DD statement, DD1.

  • 85

    VOL Backward Reference: The VOL backward reference is useful when you want to create a new data set on the same volume on which an existing data set resides, but you do not know the volume identification.

    A VOL backward reference is a coding technique that points to the volume serial number of an existing data set.

    The general form of the VOL backward reference is shown below:

    //ddname DD VOL=REF=dsname

    Example:

    //STEPA EXEC PGM=PROGA

    //DD2 DD DSN=ABC,VOL=SER=123456,

    // DISP=SHR,UNIT=SYSDA

    //DD1 DD DSN=XYZ,

    // DISP=(NEW,CATLG),

    // VOL=REF=*.DD2,

    In this example the backward reference refers to a specific volume serial number coded on a prior DD statement.

    The data set XYZ will be created on the volume referred to by the DD statement DD2 (volume 123456).

    DCB Backward Reference This coding technique can be used to ensure that the DCB parameters are consistent within the job.

    It can also be used to override or add to the subparameters coded on a previous statement.

    DCB Backward Reference Overriding DCB backward reference is a coding technique that allows you to copy a list of attributes from a prior DD statement in the same or previous job step.

    The general form is as follows:

    //ddname DD DCB=*.stepname.ddname

    The values of the DCB parameters being referredwill be overridden by the values that are being coded. Any attributes that do not match the DCB being referred will be added A DCB backward reference can also be used to override or add to the subparameters coded on a previous statement.

    The format for overriding a previous statementis as follows:

    DCB=(*.stepname.ddname,list-ofattributes)

  • 86

    For example, notice the DCB characteristics in statement DD1 below:

    //STEP3 EXEC PGM=PROG3

    //DD1 DD DCB=(RECFM=F,BLKSIZE=800),

    The following override statement:

    //DD2 DD DCB=(*.DD1,RECFM=FB,LRECL=80)

    would result in these DCB characteristics:

    //DD2 DD DCB=(RECFM=FB,

    // LRECL=80,BLKSIZE=800)

  • When a program abnormally terminates, storagedumps are used as a debugging tool to f ind cluesto the cause for abnormal ending.

    Storage dumps are not the most effective debugging tool.

    The main drawbacks of storage dumps are:

    They are difficult to read since they are printedin hexadecimal code

    Printing storage dumps is time consuming

    Storage Dumps

    Notes: When a program abnormally terminates, the user can often find clues to the reason for the ABEND in the contents of the computers storage.

    These reserved ddnames request storage dumps in the event that a program terminates abnormally:

    Special DDnames

    SYSUDUMP: Requests a formatted dump of the processing program area. It is most generally used for debugging problem programs.

    SYSABEND: Requests a formatted dump of the processing program area, system programs and the system control blocks. It is often spooled for printing, although it may be written onto any output device.

    SYSMDUMP: Requests an unformatted dump of the processing program area and the system nucleus in machine-readable form. It is generally directed to tape (or to direct access storage) to allow subsequent processing by a dump analysis utility.

    87

  • A Storage Management Subsystem (SMS) may be an optional f acility at the installation. Wheninstalled and active, the SMS manages many data sets within the installation.

    If the SMS is active, the stor