TSO-ISPF JCL COBOL VSAM DB2 CICS Tools Articles Job Portal Forum Quiz Interview Q&A

CICS HANDLE Abend


HANDLE CONDITION command intercepts only abnormal conditions of the CICS command execution whereas HANDLE ABEND takes care of any abnormal termination within the program.

  • Used to intercept an abnormal termination (ABEND) in a program

  • Used to activate, cancel or reactivate an exit for the ABEND processing


Syntax:

EXEC CICS HANDLE ABEND
       PROGRAM(name)|LABEL(ABEND-ROUTINE)|RESET|CANCEL
END-EXEC.

PROGRAM or LABEL is used to pass control to a program or a paragraph, respectively, for ABEND processing.

CANCEL is used to cancel the previously established HANDLE ABEND request.

RESET is used to reactivate the previously cancelled HANDLE ABEND request.


During the execution of the below program, the following activities will occur:

  • If an ABEND occurs, it will be intercepted by the HANDLE ABEND command, and control will be passed to ABEND-ROUTINE.

  • At the completion of the HANDLE ABEND/CANCEL command, the previous HANDLE ABEND request will be cancelled.

  • At the completion of the ABEND command, the task will be terminated with user code ‘9999’.


Example:

WORKING-STORAGE SECTION.
77 MSG-LEN           PIC S9(4) COMP.
01 MSG-DATA.
   05 MSG-DATA1      PIC X(15).
   05 MSG-DATA2      PIC X(50).
:
PROCEDURE DIVISION.
      :
      EXEC CICS HANDLE ABEND
                  LABEL(ABEND-ROUTINE)
      END-EXEC.
      :
      ABEND-ROUTINE.
      MOVE ‘ABEND OCCURED.’ TO MSG-DATA1.
      MOVE ‘TASK CANCELLED WITH ABCODE 9999.’ TO MSG-DATA2.
      MOVE  65 TO MSG-LEN.
      EXEC CICS SEND
                  FROM (MSG-DATA)
                  LENGTH(MSG-LEN)
                  NOHANDLE
      END-EXEC.
      EXEC CICS HANDLE ABEND
                 CANCEL
      END-EXEC.
      EXEC CICS ABEND
                  ABCODE(‘9999’)
      END-EXEC.

HANDLE CONDITION and IGNORE CONDITION commands remain in effect until program ends.


If you have any doubts or queries related to this chapter, get them clarified from our Mainframe experts on ibmmainframer Community!

Are you looking for Job Change? Job Portal