RPG with Integrated Language Environment (ILE) provides new ways to trap errors and perform program clean-up during unexpected program endings. These new methods are another example of why it is called the Integrated Language Environment -- they are language independent.
What's wrong with the "old" way?
Most Original program model (OPM) languages do have some sort of mechanism for trapping errors and controlling abnormal program ending. And, commitment control, when properly used, does provide a good degree of data integrity. However, both of these approaches have some serious drawbacks.
First, inherent mechanisms for trapping errors are not very robust and are fairly clumsy. Plus, since the mechanisms are language dependent, you must learn and use a different method for each language. Second, using commitment control is complicated at best for most shops. It also slows the system and can eat disk space if not properly managed.
Benefits of the ILE clean-up method
It should be made clear that you can write the code that performs the actual clean-up in any (ILE) language. It is the mechanism you use to connect your clean-up code to a program that involves the use of language-independent ILE features. Once you make the connection between the application program and the "clean-up" procedure, the system will call the "clean-up" procedure any time the associated program ends for any reason other than a normal return to caller. This includes the following events:
How to set up a clean-up procedure
In ILE, clean-up procedures are called termination exit procedures. They may be associated with any call stack entry, which means they are associated with a procedure and not an entire program. You use the CEERTX API (Register Call Stack Entry Termination User Exit Procedure ) to associate a clean-up procedure to a particular call stack entry. The clean-up procedure is associated with the call stack entry (i.e., the procedure) that calls the CEERTX API. The API accepts the following three parameters:
In the next installment, you'll see this API in action, and we'll discuss a couple of example cleanup procedures that you will be able to use as templates.
About the author: Ron Turull is editor of Inside Version 5. He has more than 20 years' experience programming for and managing AS/400-iSeries systems.