ABEND
ABEND
ABEND is used to intentionally terminate a transaction or program abnormally due to an error or unexpected situation. CICS automatically releases the main storage associated with the task that has been terminated.
Key Features -
- Terminates the current transaction immediately when an unexpected condition occurs or forcefully.
- Optionally provides a unique abend code for debugging.
- Allows rollback of uncommitted database updates (if recovery is enabled).
- Generates an entry in the CICS dump table for analysis.
The following message is sent to CEEMSG, followed by a dump report if an abend occurs - "CEE3250C An abend XXXX has occurred. XXXX specifies the transaction dump code using the ABCODE option".
Syntax -
EXEC CICS ABEND
ABCODE(abend-code)
[NODUMP]
[CANCEL]
[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.
- 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 -
Scenario1 - Using ABEND with an Error Code.
...
PROCEDURE DIVISION.
EXEC CICS LINK ...
END-EXEC.
IF WS-RESP NOT = 0 THEN
EXEC CICS ABEND
ABCODE('ERR1')
END-EXEC
END-IF.
EXEC CICS RETURN
END-EXEC.
When LINK command return code is not successful, then the program abended with ERR1 abend code.
Scenario2 - Using ABEND with NODUMP.
...
PROCEDURE DIVISION.
EXEC CICS ...
END-EXEC.
IF WS-RESP NOT = 0 THEN
EXEC CICS ABEND
ABCODE('FAIL')
NODUMP
END-EXEC
END-IF.
EXEC CICS RETURN
END-EXEC.