On the AS/400 system, there are several ways that programs can communicate status to one another. One of the main methods is to send an OS/400 message.
There are several type of OS/400 messages. These include inquiry, informational, completion, escape, and notify. For example, the final message sent by the ILE COBOL compiler when a compilation is successful is LNC0901,
Program program-name created in library library-name on date at time.
Message LNC0901 is a completion message. If a compilation fails, you will receive message LNC9001,
Compile failed. Program-name not created.
Message LNC9001 is an escape message.
An ILE condition and an OS/400 message are quite similar. Any escape, status, notify, or function check message is a condition, and every ILE condition has an associated OS/400 message.
Like OS/400 messages, which can be handled by declaring and enabling a message monitor, an ILE condition can be handled by registering an ILE condition handler. An ILE condition handler allows you to register an exception handling procedure at run time that is given control when an exception occurs. To register an exception handler, use the Register a User-Written Condition Handler (CEEHDLR) bindable API.
When a program object or an ILE procedure is called, a new call stack entry is created. Associated with each call stack entry is a call message queue. This call message queue is a program message queue if a program object is called, or a procedure message queue if an ILE procedure is called. In ILE, you can send a message to a program object or ILE procedure by sending a message to its call stack entry.
Similarly, you can signal a condition to a program object or ILE procedure by signalling a condition to its call stack entry. You can signal a condition to a program object by using ILE bindable APIs. Refer to the section on ILE bindable APIs in ILE Concepts for a list of Condition Management bindable APIs.
Each call stack entry can have several ILE condition handlers registered. When multiple ILE condition handlers are registered for the same call stack entry, the system calls these handlers in last-in-first-out (LIFO) order. These ILE condition handlers can also be registered at different priority levels. Only a few of these priorities are available to ILE COBOL. There are approximately ten distinct priorities ranging from 85 to 225. ILE condition handlers are called in increasing priority order.
In ILE, if an exception condition is not handled at a particular call stack entry, the unhandled exception message is percolated to the previous call stack entry message queue. When this happens, exception processing continues at the previous call stack entry. Percolation of an unhandled exception condition continues until either a control boundary is reached or the exception message is handled. An unhandled exception message is converted to a function check when it is percolated to the control boundary.
The function check exception message can then be handled by the call stack entry that issued the original exception condition or it is percolated to the control boundary. If the function check is handled, normal processing continues and exception processing ends. If the function check is percolated to the control boundary, ILE considers the application to have ended with an unexpected error. The generic failure exception message, CEE9901, is sent by ILE to the caller of the control boundary.
When an exception condition occurs in a program object or an ILE procedure, it is first handled by the registered ILE condition handler for the call stack entry of the program object or ILE procedure. If there is no registered ILE condition handler for the call stack entry, then the exception condition is handled by HLL-specific error handlers. HLL-specific error handlers are language features defined for handling errors. HLL-specific error handling in ILE COBOL includes the USE declarative for I/O error handling and imperatives in statement-scoped condition phrases such as ON SIZE ERROR and INVALID KEY.
If the exception condition is not handled by the HHL-specific error handling, then the unhandled exception condition is percolated to the previous call stack entry message queue, as described above.
For more information on ILE condition handling, refer to the sections on error handling, and exception and condition management in the ILE Concepts book.
(C) Copyright IBM Corporation 1992, 2005. All Rights Reserved.