Module 11: CICS Error Handling and Debugging
RESP2
RESP tells you what went wrong. RESP2 tells you why in more detail. It is an extra numeric code that CICS returns alongside RESP, giving finer detail about the failure - for example exactly which part of a file request failed. You only look at RESP2 after RESP shows an error.
What is the RESP2 option
- RESP2 is coded on the command together with RESP, for example: RESP(WS-RESP) RESP2(WS-RESP2).
- Like RESP, the RESP2 variable must be defined as PIC S9(8) COMP.
- RESP2 is only meaningful when RESP is not NORMAL. On a successful command its value is not reliable.
- CICS also fills the EIBRESP2 field after every command, so you can read the extended code there without coding RESP2.
RESP2 values are command-specific
- There is no single list of RESP2 meanings. The same RESP2 number means different things on a READ, a WRITE, or a SEND MAP.
- To decode a RESP2 value, look it up under the failing command in the CICS Application Programming Reference or the Messages and Codes manual.
- Typical uses: finding out why a file open failed, why a TS queue write was rejected, or why a map operation failed.
- In error-logging routines, always save both RESP and RESP2. Support staff need both numbers to diagnose the problem.
Example: capturing RESP2 on a TS queue write
- The example below saves both codes and includes them in the error message:WORKING-STORAGE SECTION. 01 WS-RESP PIC S9(8) COMP. 01 WS-RESP2 PIC S9(8) COMP. 01 WS-ERR-DETAIL PIC X(50). COPY DFHRESP. PROCEDURE DIVISION. EXEC CICS WRITEQ TS QUEUE('WORKQ') FROM(WORK-AREA) LENGTH(WORK-LEN) RESP(WS-RESP) RESP2(WS-RESP2) END-EXEC. IF WS-RESP NOT = DFHRESP(NORMAL) STRING 'WRITEQ TS FAILED. RESP= ' WS-RESP ' RESP2= ' WS-RESP2 DELIMITED BY SIZE INTO WS-ERR-DETAIL END-STRING PERFORM 9000-LOG-ERROR END-IF.
RESP2 good practices
- Code RESP2 only on commands where you genuinely need the extra detail. On simple reads, RESP alone is usually enough.
- Never branch program logic on a hard-coded RESP2 number without a comment saying which command it belongs to - the number is meaningless out of context.
- When reporting a problem to systems support, always quote the command, the RESP value (or condition name), and the RESP2 value together.
