Modifying default CICS exception handling
You can use the HANDLE CONDITION , IGNORE CONDITION , and HANDLE ABEND commands in your application program to modify how CICS® handles exceptions and abends.
About this task
This information applies only to COBOL, PL/I, or assembler language applications (but not AMODE(64) assembler language applications). For any other supported high level language, these commands are not supported.
- HANDLE CONDITION
- Specify the label to which control is to be passed if a condition occurs.
- IGNORE CONDITION
- Specify that no action is to be taken if a condition occurs.
- HANDLE ABEND
- Activate, cancel, or reactivate an exit for abnormal termination processing.
An abend is the most frequent way in which CICS handles exception conditions.
The current effect of the IGNORE CONDITION , HANDLE ABEND , and HANDLE CONDITION commands can be suspended by using the PUSH HANDLE command, and reinstated by using the POP HANDLE command.
- Use a HANDLE CONDITION condition(label) command, where condition is the name of an exception condition.
- Use a HANDLE CONDITION ERROR(label) command.
The HANDLE CONDITION command sets up CICS code to name specific conditions, and then uses this code to pass control to appropriate sections of your application if those conditions arise. With an active HANDLE CONDITION command, control goes to the label that you specified for that specific condition.
The same condition might occur on many different commands, and for different reasons. For example, an IOERR condition can occur during file control operations, interval control operations, and others. Therefore, you need to identify the command that has raised a specific condition before you can investigate why it has happened. This is a good reason for using the RESP option in new CICS applications. Although you need only one HANDLE CONDITION command to set error-handling for several conditions, sometimes it is awkward to identify exactly which of several HANDLE CONDITION commands is currently active when a CICS command fails somewhere in your code.
If a condition that you have not named occurs, CICS takes the default action, unless this action is to abend the task, in which case it raises the ERROR condition. If you name the condition but leave out its label, any HANDLE CONDITION command for that condition is deactivated, and if the condition occurs, CICS takes the default action.
A common source of errors with the HANDLE CONDITION command is not dealing with all conditions. If you use an unfamiliar command, check the command description to find out which exception conditions are possible (see ). Even when you issue HANDLE commands for all the exception conditions, the error-handling code might not be finished. Sometimes the result is an error-handling routine that, by issuing a RETURN command, allows incomplete or incorrect data changes to be committed.
A good approach is to use the HANDLE CONDITION command, but to let the system default action proceed if there is no obvious way round a specific problem.
Bearing in mind the distinction between an error condition, a condition that merely causes a wait (see How CICS keeps track of what to do for examples of conditions that cause a wait), and the special case of the SEND MAP command overflow processing, a HANDLE CONDITION command is active after a HANDLE CONDITION condition(label), or HANDLE CONDITION ERROR(label) command has been run in your application.
If no HANDLE CONDITION command is active for a condition, but one is active for ERROR, control passes to the label for ERROR, if the condition is an error, not a wait.
If you use HANDLE CONDITION commands, or are maintaining an application that uses them, do not include any commands in your error routine that can cause the same condition that gave you the original branch to the routine, because you will cause a loop.
Take special care not to cause a loop on the ERROR condition itself. You can avoid a loop by reverting temporarily to the system default action for the ERROR condition. Do this by coding a HANDLE CONDITION ERROR command with no label specified. At the end of your error processing routine, you can reinstate your error action by including a HANDLE CONDITION ERROR command with the appropriate label. If you know the previous HANDLE CONDITION state, you can do this explicitly. In a general subroutine, which might be called from several different points in your code, the PUSH HANDLE and POP HANDLE commands might be useful. See Using PUSH HANDLE and POP HANDLE commands.