Error Handling
CICS commands may cause errors during their execution within an application program, which causes the program to abend (abnormally end). This results in an incomplete task. It's important to handle these errors to ensure the program executes successfully.
CICS offers default error handling methods for some expected errors. When an error condition occurs, there are four different strategies to manage it effectively -
- Letting the program continue
- Pass control to a specified label
- Do nothing and rely on the CICS system default action
- Mix the methods in any way based on requirement
1. Letting the program continue -
When a command failedwith error, the program halts execution and becomes abended. However, allowing the program to continue can help it process known errors without interruption. There are three effective methods to achieve this:
- Put the RESP option on the command.
- Put the NOHANDLE option on the command.
- Use an IGNORE CONDITION command.
2. Pass control to a specific label or paragraph -
This can be done when predefined error condition occurred. The below is the way of passing control to a specified label –
- EXEC CICS HANDLE CONDITION ERROR (label) command.
3. Do nothing and rely on the CICS system default action -
This option is perfectly sensible in some cases and means doing nothing regarding testing or handling conditions. The CICS default action is normally to abend the task, but not always.
Error Support Commands -
Command | Description |
---|---|
HANDLE CONDITION | Used to specify the control passing label or paragraph if a specified condition occurs. |
INGORE CONDITION | Used to specify that no action is taken if a specified condition occurs. |
PUSH HANDLE | Used to suspend the current effect of the HANDLE CONDITION, IGNORE CONDITION, HANDLE ABEND and HANDLE AID commands. |
POP HANDLE | Used to restore the previous effect of the HANDLE CONDITION, IGNORE CONDITION, HANDLE ABEND and HANDLE AID commands. That is right before PUSH HANDLE command execution. |
Abend Support Commands -
Command | Description |
---|---|
ABEND | Terminates a task abnormally |
HANDLE ABEND | Used to activate, cancel or reactivate an exit for abnormal termination processing. |