Module 3: CICS Transactions and Commands
EXEC CICS
EXEC CICS is the doorway between your program and CICS. COBOL has no verbs for screens, files under CICS, or task control — EXEC CICS provides them all.
Why EXEC CICS exists
- Native COBOL can read sequential files, but it cannot talk to a terminal, start another transaction, or get CICS storage.
- EXEC CICS is the application programming interface (API) of CICS — every service request goes through it.
- The same EXEC CICS format works in COBOL, PL/I, C and Assembler programs.
- There are well over 100 CICS commands, but most programs use the same 15–20 every day.
What the translator does with it
- Before compiling, the CICS translator scans the source for EXEC CICS blocks.
- Each block becomes one or more CALL statements to CICS modules, with your options turned into a parameter list.
- The translator inserts DFHEIBLK (the Execute Interface Block) into the LINKAGE SECTION automatically.
- EIB fields like EIBTRNID, EIBAID and EIBCALEN let the program see what just happened.
Checking the response code
- Almost every command can raise an exceptional condition, like NOTFND, DUPKEY, or MAPFAIL.
- Code the RESP option to receive the response code, then test it with the DFHRESP built-in function.
- If you do not code RESP or HANDLE CONDITION, CICS abends the task on an exceptional condition.
- Example of EXEC CICS with proper response-code checking:-
*--- EXEC CICS with response-code checking ---* EXEC CICS READ FILE('CUSTMAS') INTO(CUSTOMER-RECORD) RIDFLD(WS-CUST-NO) RESP(WS-RESP) END-EXEC. EVALUATE WS-RESP WHEN DFHRESP(NORMAL) CONTINUE WHEN DFHRESP(NOTFND) MOVE 'CUSTOMER NOT FOUND' TO WS-MESSAGE WHEN OTHER MOVE 'READ FAILED' TO WS-MESSAGE END-EVALUATE.
