Module 15: CICS Real-World Projects and Interview Preparation
CICS Coding Questions
Coding interviews ask you to write small CICS snippets on the spot: a file read, a map send, a browse loop, a pseudo-conversational skeleton.
Write these from memory until they are automatic - that is exactly what interviewers are checking.
Write-the-code questions
- Q: Write an EXEC CICS READ with NOTFND handling. A: Code READ with RESP, then IF WS-RESP = DFHRESP(NOTFND) move an error message.
- Q: Write the SEND MAP and RECEIVE MAP pair. A: SEND MAP with MAPSET and ERASE to display; RECEIVE MAP INTO the symbolic map to read input.
- Q: Write a TSQ write/read pair for passing data between programs. A: EXEC CICS WRITEQ TS QUEUE('MYQ') FROM(data) then EXEC CICS READQ TS QUEUE('MYQ') INTO(data) ITEM(1).
- Q: Write XCTL with a COMMAREA. A: EXEC CICS XCTL PROGRAM('PROG2') COMMAREA(WS-AREA) LENGTH(50) END-EXEC.
- Example:-
EXEC CICS READ FILE('CUSTMAS') INTO(CUSTOMER-MASTER-RECORD) RIDFLD(WS-CUST-NO) RESP(WS-RESP) END-EXEC. IF WS-RESP = DFHRESP(NOTFND) MOVE 'CUSTOMER NOT FOUND' TO MSGO END-IF. EXEC CICS WRITEQ TS QUEUE('PASSQ') FROM(WS-PASS-DATA) LENGTH(100) END-EXEC.
Logic questions
- Q: Write the pseudo-conversational skeleton. A: If EIBCALEN = 0, SEND the first map and RETURN TRANSID with COMMAREA; else RECEIVE MAP and process the input.
- Q: Write a browse loop over a file. A: STARTBR with GTEQ, then READNEXT in a PERFORM UNTIL NOT NORMAL, then ENDBR.
- Q: How do you position the browse at a generic key? A: STARTBR with RIDFLD holding the partial key and the GENERIC option with KEYLENGTH.
- Example:-
0000-MAINLINE. IF EIBCALEN = 0 MOVE LOW-VALUES TO INQMAPO EXEC CICS SEND MAP('INQMAP') MAPSET('INQSET') ERASE END-EXEC EXEC CICS RETURN TRANSID('INQ1') COMMAREA(WS-COMMAREA) LENGTH(10) END-EXEC ELSE EXEC CICS RECEIVE MAP('INQMAP') MAPSET('INQSET') INTO(INQMAPO) END-EXEC PERFORM 1000-PROCESS-INPUT END-IF. EXEC CICS STARTBR FILE('CUSTMAS') RIDFLD(WS-LOW-KEY) GTEQ RESP(WS-RESP) END-EXEC. PERFORM UNTIL WS-RESP NOT = DFHRESP(NORMAL) EXEC CICS READNEXT FILE('CUSTMAS') INTO(CUSTOMER-MASTER-RECORD) RIDFLD(WS-CUST-NO) RESP(WS-RESP) END-EXEC IF WS-RESP = DFHRESP(NORMAL) PERFORM 3000-DISPLAY-RECORD END-IF END-PERFORM. EXEC CICS ENDBR FILE('CUSTMAS') END-EXEC.
Spot-the-bug questions
- Q: The program SENDs a map then RETURNs without TRANSID. What breaks? A: The conversation ends - the next user input starts nothing. Pseudo-conversational programs must RETURN with TRANSID.
- Q: REWRITE is coded but there was no READ UPDATE. What happens? A: INVREQ - REWRITE needs the record locked by a READ UPDATE in the same task.
- Q: The program does RECEIVE MAP but the screen was never SENT. What happens? A: MAPFAIL or unexpected input - RECEIVE needs a prior SEND, or the terminal input must already be there.
- Q: WORKING-STORAGE holds the account number across two screens. What is wrong? A: WORKING-STORAGE is fresh on every task restart. Carry the value in the COMMAREA instead.
