CICS - Handle condition



Handle condition is used to transfer the control of the program to a paragraph or a procedure label. If the condition name specified in the exception block arises, the particular para will be given control and then we can handle that condition.

HANDLE CONDITION can handle only conditions related to CICS, not the ordinary program Abends like as data exceptions. It can handle conditions that are related only to CICS. It cannot handle the ordinary program Abends like as data exceptions. The syntax of Handle Condition is as follows −

Syntax

EXEC CICS HANDLE CONDITION
   CONDITION(Label)
   CONDITION(Label)
   ERROR(LABEL)
END-EXEC.

Example

Following is the example of Handle condition −

IDENTIFICATION DIVISION.                                         
PROGRAM-ID. HELLO.                                               
PROCEDURE DIVISION.

EXEC CICS HANDLE CONDITION
   DUPKEY(X0000-DUPKEY-ERR-PARA)
   NOTFND(X000-NOT-FOUND-PARA)
   ERROR(X0000-GEN-ERR-PARA)
END-EXEC.
X0000-DUPKEY-ERR-PARA.

DISPLAY 'Duplicate Key Found'.
X0000-NOT-FOUND-PARA.

DISPLAY 'Record Not Found'.
X0000-GEN-ERR-PARA.

DISPLAY 'General Error'.
cics_error_handling.htm
Advertisements