You can code one or more USE AFTER EXCEPTION/ERROR declarative procedures in your ILE COBOL program that will be given control if an input-output error occurs. You can have:
Place each such procedure in the declaratives section of the Procedure Division of your program. Refer to the WebSphere Development Studio: ILE COBOL Reference for details about how to write a declarative.
In your procedure, you can choose to attempt corrective action, retry the operation, continue, or end the program. Your can use the USE AFTER EXCEPTION/ERROR declarative procedure in combination with the status key if you want further analysis of the error.
For GLOBAL files, each ILE COBOL program can have its own USE AFTER EXCEPTION/ERROR declarative procedure.
USE AFTER EXCEPTION/ERROR declarative can themselves be declared GLOBAL. Special precedence rules are followed when multiple declaratives may be performed on an I/O error. In applying these rules, only the first qualifying declarative will be selected for execution. The declarative that is selected must satisfy the rules for execution of that declarative. The order of precedence for selecting a declarative is:
Write a USE AFTER EXCEPTION/ERROR declarative procedure if you want to return control to your program after an error occurs. If you don't write such a procedure, your job may be cancelled or abnormally ended after an error occurs.
Each USE AFTER EXCEPTION/ERROR declarative procedure runs as a separate invocation from that of other declarative procedures and the non-declarative part of the same ILE COBOL program. Thus, if you call the CEEHDLR API to register an ILE condition handler from a declarative procedure, that ILE condition handler is invoked only for exceptions that occur in the USE AFTER EXCEPTION/ERROR declarative procedure and not for exceptions that occur in any other part of the ILE COBOL program.
(C) Copyright IBM Corporation 1992, 2005. All Rights Reserved.