You are on page 1of 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.
Introduction Continued ….

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.
SPOOLOPEN

With SPOOLOPEN command, spool file is set up for


SPOOLWRITE.
The command for SPOOLOPEN:
EXEC CICS
SPOOLOPEN OUTPUT NODE(‘*’)
USERID(‘INTRDR ‘)
TOKEN(rp_token)
RESP(rs_ field)
NOCC
END-EXEC.
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.
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.
SPOOLWRITE

The command for SPOOLWRITE:


EXEC CICS
SPOOLWRITE FROM(data-field)
TOKEN(rp_token)
FLENGTH(data_length)
RESP(rs_field)
END-EXEC.
SPOOLWRITE Continued …….
FROM  The data field that contains the
line of JCL to be spooled.
TOKEN  The same 8 bytes of information
as in SPOOLOPEN.
FLENGTH  Length of the data being written
to the SPOOL.
RESP  Response value.

Spool files are sequential. Each SPOOLWRITE is treated


as a new record. Once all the necessary lines of JCL
are written to SPOOL, the task is released to the JES
for processing by SPOOLCLOSE command.
SPOOLCLOSE

EXEC CICS
SPOOLCLOSE TOKEN(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 JES
that acts like a normal Batch Job.
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.
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.
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 the
length of the variable specified in the WRITE
command.
 
Sample Cobol II Program to submit
JCL 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.
 
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 DD DSN=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.
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-EXIT
END-IF.
1000-EXIT.
EXIT.
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-EXIT
END-IF.
ADD 1 TO WS-I

2000-EXIT.
EXIT.
 
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-EXIT
END-IF.
3000-EXIT.
EXIT.
9999-STOP.
EXEC CICS
RETURN
END-EXEC.
9999-EXIT.
EXIT.
Note: To write the entire JCL, SPOOL is opened once. SPOOLWRITE is
repeated for every line of JCL. Once all the lines are written to the spool,
it is closed.
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.
// DD DSN=TPE037.TEST.ERROR,
// DISP=(MOD,DELETE,DELETE),SPACE=(TRK,(1,1),RLSE)
//*
 
Advantages
Transient Data Queues (TDQ) is another traditional way
of CICS interface to JES.

Shortfalls of TDQ :
• Single-threading queuing mechanisms within
applications 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.
 
Advantages
Transient Data Queues (TDQ) is another traditional way
of CICS interface to JES.

Shortfalls of TDQ :
• Single-threading queuing mechanisms within
applications 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.
 

You might also like