Thursday, December 8, 2011

CICS: Submit job using SPOOL commands


Occasionally you may wish to submit a batch job (JCL) to JES from CICS. CICS provides an interface to JES to allow you to submit JCL to the internal reader. You submit JCL using the SPOOLOPEN, SPOOLWRITE and SPOOLCLOSE commands.
To access the SPOOL:

1) First you must open a spool for output using SPOOLOPEN
EXEC CICS
 SPOOLOPEN OUTPUT NODE('*') USERID(INTRDR)
 TOKEN(report_token) RESP(response field)
END-EXEC.

NODE('*') specifies a destination node to send the JCL to. USERID is set to the name of the internal reader INTRDR
A unique token will be allocated by CICS when the SPOOLOPEN is executed and placed in the field you specify using TOKEN(report_token). The token will be used as asending field on subsequent commands. The token will be 8 bytes long.  RESP must be coded, allowing you to check if the command executed successfully.
 
2) To write each line of the job to the spool use the SPOOLWRITE command.
EXEC CICS
 SPOOLWRITE FROM(io_area) TOKEN(report_token)
 RESP(resonse_field)
END-EXEC.
The "io_area" field should be the name of a data item containing the line of JCL.The "report_token" field should be the same as the 8 byte token returned from SPOOLOPEN.
An end of job statement ('//' or '/*EOF') should be written as the last line.

3) Finally you must close the spool using SPOOLCLOSE. (Note if you do not explicitly close the spool it will be closed when the transaction terminates, However it is good practice to close the spool explicitly)
EXEC CICS
 SPOOLCLOSE TOKEN(report_token) RESP(response_field)
END-EXEC.
Again the "report_token" field must be the same as the one allocated at SPOOLOPEN
Note that in order to use this method DFHSIT SPOOL=YES must be coded in the CICS System Initialization Table. Check with your friendly local SysProg if you are unsure.

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.