17686425-ModJob-Submission-From-CICS

download 17686425-ModJob-Submission-From-CICS

of 19

Transcript of 17686425-ModJob-Submission-From-CICS

  • 8/7/2019 17686425-ModJob-Submission-From-CICS

    1/19

    Introduction

    When we talk about CICS the only thing that comes

    to our mind is its wide usage for online transactions

    like inquiry, updating the database etc.

    Other interesting thing that one can do with CICS is

    submitting batch job (JCL) to JES (Job Entry

    Subsystem) using SPOOL files.

  • 8/7/2019 17686425-ModJob-Submission-From-CICS

    2/19

    CICS provides an interface to JES that allows us to

    submit JCL to the Internal Reader, which is done

    using SPOOLOPEN, SPOOLWRITE and SPOOLCLOSE

    commands.

    These commands can be used in JES2 or JES3 form

    of JES.

    Spool files directed to JES Internal Reader are

    treated as complete Job and executed.

    Introduction Continued .

  • 8/7/2019 17686425-ModJob-Submission-From-CICS

    3/19

    SPOOLOPEN

    With SPOOLOPEN command, spool file is set up for

    SPOOLWRITE.

    The command for SPOOLOPEN:

    EXEC CICS

    SPOOLOPENOUTPUTNODE(*)

    USERID(INTRDR )

    TOKEN(rp_token)

    RESP(rs_ field)

    NOCC

    END-EXEC.

  • 8/7/2019 17686425-ModJob-Submission-From-CICS

    4/19

    SPOOLOPEN Continued .

    NODE(*) Destination node to direct the JCL.

    This is 8 bytes field. If the node

    name is less than 8 bytes, pad it

    with spaces.

    TOKEN The identifier returned by CICS for the

    spool file. The same token has

    to be used for subsequent

    commands. It is a mandatory

    field of 8 bytes.

  • 8/7/2019 17686425-ModJob-Submission-From-CICS

    5/19

    SPOOLOPEN Continued .

    USERID Is the name of the Internal Reader

    that is set to INTRDR. If it is less

    than 8 bytes, pad it with spaces.

    RESP It holds the return code, indicating

    success (0) or failure (>0) of

    command execution.NOCC To prevent use of the first characters

    for carriage control.

  • 8/7/2019 17686425-ModJob-Submission-From-CICS

    6/19

    SPOOLWRITE

    The command for SPOOLWRITE:

    EXEC CICS

    SPOOLWRITEFROM(data-field)

    TOKEN(rp_token)

    FLENGTH(data_length)

    RESP(rs_field)END-EXEC.

  • 8/7/2019 17686425-ModJob-Submission-From-CICS

    7/19

    SPOOLWRITE Continued .

    FROM The data field that contains theline of JCL to be spooled.

    TOKEN The same 8 bytes of informationas in SPOOLOPEN.

    FLENGTH Length of the data being writtento the SPOOL.

    RESP Response value.

    Spool files are sequential. Each SPOOLWRITE is treatedas a new record. Once all the necessary lines of JCL

    are written to SPOOL, the task is released to the JESfor processing by SPOOLCLOSE command.

  • 8/7/2019 17686425-ModJob-Submission-From-CICS

    8/19

    SPOOLCLOSE

    EXEC CICS

    SPOOLCLOSETOKEN(rp_token)

    RESP(rs_field)

    END-EXEC.

    TOKEN and RESP have the same functionality as

    mentioned in SPOOLOPEN/SPOOLWRITE.

    Once the SPOOL is closed, JCL gets submitted to JESthat acts like a normal Batch Job.

  • 8/7/2019 17686425-ModJob-Submission-From-CICS

    9/19

    Prerequisites for using SPOOL

    One should be aware of the Node for the system. It

    is the JES subsystem name defined within the

    system.

    The System Initialization Table (SIT) should have

    SPOOL=YES.

  • 8/7/2019 17686425-ModJob-Submission-From-CICS

    10/19

    Good to Have points

    One should make use of RESP or NOHANDLE on all

    spool commands. After each OPEN, WRITE or CLOSE

    command one should check the RESP value.

    Use of RESP2 is recommended. Additional

    information about some exception condition is

    returned in this field.

  • 8/7/2019 17686425-ModJob-Submission-From-CICS

    11/19

    Notes

    If the SPOOL is not closed explicitly, it gets closed at

    the time of transaction termination. But it is always a

    good idea to close it.

    In newer versions of COBOL, FLENGTH in SPOOLWRITE

    is not mandatory. It will automatically pick up thelength of the variable specified in the WRITEcommand.

  • 8/7/2019 17686425-ModJob-Submission-From-CICS

    12/19

    Sample Cobol II Program to submitJCL to JES

    IDENTIFICATION DIVISION.

    PROGRAM-ID.SPOOLTT.

    ENVIRONMENT DIVISION.

    DATA DIVISION.WORKING-STORAGE SECTION.

    01 WS-SPOOLVARS.05 WS-TOK PIC X(08) VALUE SPACES.

    05 WS-RESP PIC S9(04) COMP.

    05 WS-NODE PIC X(08) VALUE J2SIG .

    05 WS-READER PIC X(08) VALUE INTRDR .01 WS-I PIC 9(02) VALUE 1.

  • 8/7/2019 17686425-ModJob-Submission-From-CICS

    13/19

    Sample Program Continued .

    01 WS-JOBSTREAM.05 WS-JOBSTMT PICTURE X(80)

    VALUE //TLPSC001 JOB (0807LS01),EMP PROCESSING,.05 WS-JOBAUTH PICTURE X(80)

    VALUE // CLASS=K,MSGCLASS=1,NOTIFY=TPE037.

    05 FILLER PICTURE X(80)VALUE //*.

    05 WS-JOBSTEP1 PICTURE X(80)

    VALUE //DELSTEP EXEC PGM=IEFBR14.05 WS-JOBSTEP2 PICTURE X(80)

    VALUE //DD01 DDDSN=TPE037.TEST.ERROR,.

    05 WS-JOBSTEP3 PICTURE X(80)VALUE // DISP=(,DELETE,DELETE), SPACE=(TRK,(1,1),RLSE).

    05 FILLER PICTURE X(80)

    VALUE //*.01 WS-JOBSPOOL REDEFINES JOBSTREAM PIC X(80) OCCURS 7 TIMES.

  • 8/7/2019 17686425-ModJob-Submission-From-CICS

    14/19

    Sample Program Continued .

    PROCEDURE DIVISION.

    0000-MAIN-PARA.PERFORM 1000-OPEN-SPOOL THRU 1000-EXIT.

    PERFORM 2000-WRITE-SPOOL THRU 2000-EXIT UNTIL WS-I > 7.PERFORM 3000-CLOSE-SPOOL THRU 3000-EXIT.

    PERFORM 9999-STOP THRU 9999-EXIT.0000-EXIT.

    EXIT.

    1000-OPEN-SPOOL.

    EXEC CICS SPOOLOPEN OUTPUT NODE(WS-NODE)TOKEN (WS-TOK)

    USERID (WS-READER)RESP(WS-RESP)

    END-EXEC.

    IF WS-RESP NOT = 0

    PERFORM 9999-STOP THRU 9999-EXITEND-IF.

    1000-EXIT.EXIT.

  • 8/7/2019 17686425-ModJob-Submission-From-CICS

    15/19

    Sample Program Continued .

    2000-WRITE-SPOOL.

    EXEC CICS SPOOLWRITE FROM(WS-JOBSPOOL(WS-I))

    FLENGTH(80)

    TOKEN(WS-TOK)RESP(WS-RESP)

    END-EXEC.IF WS-RESP NOT = 0

    PERFORM 9999-STOP THRU 9999-EXITEND-IF.

    ADD 1 TO WS-I

    2000-EXIT.EXIT.

  • 8/7/2019 17686425-ModJob-Submission-From-CICS

    16/19

    Sample Program Continued .

    3000-CLOSE-SPOOL.

    EXEC CICS SPOOLCLOSE TOKEN (WS-TOK)RESP(WS-RESP)

    END-EXEC.IF WS-RESP NOT = 0

    PERFORM 9999-STOP THRU 9999-EXITEND-IF.

    3000-EXIT.

    EXIT.

    9999-STOP.

    EXEC CICS

    RETURNEND-EXEC.

    9999-EXIT.

    EXIT.

    Note: To write the entire JCL, SPOOL is opened once. SPOOLWRITE isrepeated for every line of JCL. Once all the lines are written to the spool,

    it is closed.

  • 8/7/2019 17686425-ModJob-Submission-From-CICS

    17/19

    Sample Program Continued .

    When the above program is executed in the CICS region,

    the following job is submitted to JES.

    //TLPSC001 JOB (0807LS01),EMP PROCESSING,// CLASS=K,MSGCLASS=1,NOTIFY=TPE037

    //*//DELSTEP EXEC PGM=IEFBR14.

    // DDDSN=TPE037.TEST.ERROR,

    // DISP=(MOD,DELETE,DELETE),SPACE=(TRK,(1,1),RLSE)

    //*

  • 8/7/2019 17686425-ModJob-Submission-From-CICS

    18/19

    Advantages

    Transient Data Queues (TDQ) is another traditional way

    of CICS interface to JES.

    Shortfalls ofTDQ:

    Single-threading queuing mechanisms withinapplications to avoid interspersing one user's JCL with

    that from another.

    Performance problems due to high transaction

    volumes.

    Both these problems are well handled in CICS-JES Spool

    as each user is assigned a unique token that in turn

    permits multithreading.

  • 8/7/2019 17686425-ModJob-Submission-From-CICS

    19/19

    Advantages

    Transient Data Queues (TDQ) is another traditional way

    of CICS interface to JES.

    Shortfalls ofTDQ:

    Single-threading queuing mechanisms withinapplications to avoid interspersing one user's JCL with

    that from another.

    Performance problems due to high transaction

    volumes.

    Both these problems are well handled in CICS-JES Spool

    as each user is assigned a unique token that in turn

    permits multithreading.