How to Handle Errors in CICS

Handling Errors Method -1

The first method is to write an error program of re-usable to call whenever you need.

WORKING-STORAGE SECTION.
 *
 COPY ERRPARM.
C 01 ERROR-PARAMETERS.
C *
C 05 ERR-RESP PIC S9(8) COMP.
C 05 ERR-RESP2 PIC S9(8) COMP.
C 05 ERR-TRNID PIC X(4).
C 05 ERR-RSRCE PIC X(8).
 .
 .
 PROCEDURE DIVISION.
 .
 .
 IF RESPONSE-CODE NOT = DFHRESP(NORMAL)
 PERFORM 9999-TERMINATE-PROGRAM.
 .
 .
 9999-TERMINATE-PROGRAM.
 *
 MOVE EIBRESP TO ERR-RESP.
 MOVE EIBRESP2 TO ERR-RESP2.
 MOVE EIBTRNID TO ERR-TRNID.
 MOVE EIBRSRCE TO ERR-RSRCE.
 EXEC CICS 
    XCTL PROGRAM('SYSERR') 
    COMMAREA(ERROR-PARAMETERS)
 END-EXEC.

Here, ‘SYSERR’ is the re-usable error sub-routine.

Also Read: CICS Tough Interview questions part 1 of 3

What is an error io sub-routine

  • An error handling program usually displays an error message to the user and does extensive processing, including writing detailed error information to an error log, reversing any changes that were made to recoverable files, and producing a storage dump.
  • It may also cause the program to abend, or it may just end with a RETURN command.
  • Any program that branches to the error handling program will probably be required to pass along information on its current status, including information that’s available in the Execute Interface Block.

Handling Errors Method -2

Sending an error message to user through CICS screen. This error message you can write in your main program.

 EXEC CICS
       SEND TEXT FROM(ERROR-MESSAGE)
       ERASE
       ALARM
       FREEKB
 END-EXEC.

Related posts

Author: Srini

Experienced software developer. Skills in Development, Coding, Testing and Debugging. Good Data analytic skills (Data Warehousing and BI). Also skills in Mainframe.