The CICS application should use the CICS SPOOLOPEN, SPOOLWRITE and SPOOLCLOSE commands and be compiled with a non-mainframe dialect, with the CICSECM directive set.
WORKING-STORAGE SECTION. 01 WS-RESP1 PIC S9(9) COMP. 01 WS-RESP2 PIC S9(9) COMP. 01 WS-TOKEN PIC X(8) VALUE SPACE. 01 WS-JCL-LINES. 03 FILLER PIC X(80) VALUE '//MFIPEH JOB MTS,PEH,CLASS=A,MSGCLASS=O'. 03 FILLER PIC X(80) VALUE '//* CHECK CICS SPOOL API '. 03 FILLER PIC X(80) VALUE '// EXEC PGM=IEFBR14'. 03 FILLER PIC X(80) VALUE '// '. 01 FILLER REDEFINES WS-JCL-LINES. 03 WS-JCL PIC X(80) OCCURS 4 INDEXED BY WS-JIX. 01 WS-ERROR. 03 FILLER PIC X(24) VALUE 'ERROR OCCURRED. RESP1 = '. 03 WS-ERR1 PIC +9(8). 03 FILLER PIC X(10) VALUE ', RESP2 = '. 03 WS-ERR2 PIC +9(8). 01 WS-RUN-OK PIC X(20) VALUE 'Test run OK'. 01 WS-POINTER POINTER. 01 WS-OUT-DESCR. 03 FILLER PIC X(26) VALUE 'USERID(XXXXXX) DEST(JES2W)'. LINKAGE SECTION. 01 LK-OUT-DESCR. 03 LK-LEN PIC S9(8) COMP. 03 LK-OUT-DATA PIC X(26). 03 LK-POINTER POINTER. PROCEDURE DIVISION. EXEC CICS GETMAIN SET(WS-POINTER) LENGTH(LENGTH OF LK-OUT-DESCR) END-EXEC SET ADDRESS OF LK-OUT-DESCR TO WS-POINTER MOVE WS-OUT-DESCR TO LK-OUT-DATA MOVE LENGTH OF LK-OUT-DATA TO LK-LEN SET LK-POINTER TO WS-POINTER SET WS-POINTER TO ADDRESS OF LK-POINTER EXEC CICS SPOOLOPEN OUTPUT TOKEN(WS-TOKEN) USERID('XXXXXX') NODE('N1') RESP(WS-RESP1) RESP2(WS-RESP2) END-EXEC IF WS-RESP1 NOT = DFHRESP(NORMAL) GO TO ERR-DISP END-IF SET WS-JIX TO 1 PERFORM 4 TIMES EXEC CICS SPOOLWRITE TOKEN(WS-TOKEN) FROM(WS-JCL(WS-JIX)) RESP(WS-RESP1) RESP2(WS-RESP2) END-EXEC IF WS-RESP1 NOT = DFHRESP(NORMAL) GO TO ERR-DISP END-IF SET WS-JIX UP BY 1 END-PERFORM EXEC CICS SPOOLCLOSE TOKEN(WS-TOKEN) RESP(WS-RESP1) RESP2(WS-RESP2) END-EXEC IF WS-RESP1 NOT = DFHRESP(NORMAL) GO TO ERR-DISP END-IF EXEC CICS SEND TEXT FROM(WS-RUN-OK) ERASE FREEKB END-EXEC EXEC CICS RETURN END-EXEC GOBACK. ERR-DISP. MOVE WS-RESP1 TO WS-ERR1 MOVE WS-RESP2 TO WS-ERR2 EXEC CICS SEND TEXT FROM(WS-ERROR) ERASE END-EXEC EXEC CICS RETURN END-EXEC .