Thread: CICS

RESP versus HANDLE CONDITION for DB2 errors in COBOL

Started by James • user4 replies304 viewsLast activity 1 month ago
Post #1
0 votes
James
Reputation
524
Posts: 8
Joined: May 2, 2024, 8:00 AM
Posted: Jun 5, 2026, 11:33 AM

Colleagues,

Our standards committee is reviewing error handling for new CICS COBOL programs that call DB2. Legacy modules use HANDLE CONDITION ERROR to branch to a common error section. Newer guidance in our internal wiki favors checking EIBRESP and SQLCODE explicitly after each command.

Representative legacy pattern:

cobol
EXEC CICS HANDLE CONDITION
    ERROR(ERROR-ROUTINE)
    NOTFND(MISSING-RECORD)
END-EXEC.

EXEC CICS READ FILE('CUSTMAST')
     INTO(CUSTOMER-RECORD)
     RIDFLD(CUST-KEY)
END-EXEC.

The IBM CICS Application Programming Reference notes:

The RESP option can be used to obtain a response code without affecting the flow of control through the HANDLE CONDITION mechanism.

My question: for maintainability, is it reasonable to prohibit new HANDLE CONDITION usage entirely, or are there vetted cases where it remains preferable?

Regards,
James

Post #2
0 votes
Dave
Reputation
356
Posts: 8
Joined: Jul 21, 2024, 2:55 PM
Posted: Jun 5, 2026, 3:33 PM

We allow HANDLE for NOTFND on browse-heavy programs where RESP on every READ adds noise. Everything else must use RESP or RESP2 with explicit evaluation.

For DB2 specifically, HANDLE does not replace SQLCODE checking. That remains mandatory in our shop.

Post #3
0 votes
James
Reputation
524
Posts: 8
Joined: May 2, 2024, 8:00 AM
Posted: Jun 6, 2026, 1:33 PM

That aligns with our direction. Follow-up: do you document permitted exceptions in a coding standard, or leave it to code review judgment?

Post #4
0 votes
Dave
Reputation
356
Posts: 8
Joined: Jul 21, 2024, 2:55 PM
Posted: Jun 6, 2026, 7:33 PM

Documented. Appendix B of our CICS standard lists three allowed HANDLE cases with examples. Anything else fails review.

You must be signed in to reply to this thread