HANDLE ABEND


The CICS HANDLE ABEND statement is used to trap and handle abnormal terminations (abends) in a controlled manner. It allows you to activate, cancel, or reactivate an exit for handling abnormal terminations.

When a task terminates abnormally, CICS searches for an active abend exit in the application program where the abnormal termination occurred and continues to search at progressively higher levels.

The COMMAREA that is passed to the abend exit is the one from the program that issued the HANDLE ABEND command.

Key Features -

  • Intercepts and handles program abends before CICS terminates the transaction.
  • Transfers control to an error routine instead of stopping execution immediately.
  • Supports automatic recovery and restart mechanisms.
  • Can be disabled using the NOHANDLE option when needed.

Syntax -

EXEC CICS HANDLE ABEND
	 [CANCEL]
	 [RESET]
	 [PROGRAM (program-name)]
     LABEL(error-label)
     [RESP(response-field)]
     [RESP2(response-field2)]
     END-EXEC.
  • ABCODE(abend-code) - Specifies the four-character abend code to identify the reason for abnormal termination.
  • NODUMP - Prevents CICS from taking a transaction dump (used when debugging is not required).
  • CANCEL - An ABEND CANCEL command cancels all exits at any task level and terminates the task abnormally.
  • RESET - Default. Specifies that a previously established exit at the logical level of the application program in control is canceled.
  • RESP(response-variable) - Optional. It captures the response code of the ABEND operation and used to check if the command executed successfully or encountered an error.
  • RESP2(response2-variable) - Optional. It captures the response2 code of the ABEND operation when the error occured.

Short Examples -


Scenario - Using ABEND with an Error Code.

...
PROCEDURE DIVISION.

    EXEC CICS HANDLE ABEND
         LABEL(HANDLING-ERROR)
         END-EXEC.
		 
	EXEC CICS LINK
	 PROGRAM(WS-SUBPROG)
	 COMMAREA(WS-COMMAREA)
	 LENGTH(50)
	 RESP(WS-RESP-CODE)
	 END-EXEC.

    IF WS-RESP NOT = 0 THEN
       ...
	END-IF.

    ...
HANDLING-ERROR.
    MOVE "ERROR: Error occurred"
	  to ERROR-MSG
	  
    EXEC CICS RETURN
         END-EXEC.

When error occured in the LINK statement, the control transferred to HANDLING-ERROR paragraph.

Error Conditions -


Eror Condition RESP RESP2 Reason
PGMIDERR 27 1 The program has no installed resource definition and auto install for programs is not active.
27 2 The program is disabled.
27 9 The installed program resource definition is for a remote program.
NOTAUTH 70 Occurs when a resource security check has failed on PROGRAM (name).