IBM AS/400 Frozen Dessert Maker User Manual


 
*=================================================================*
* *PSSR: Error Subroutine for the procedure *
*=================================================================*
C *PSSR BEGSR
C EXCEPT InPssr
C EXCEPT Cancelling
C ENDSR '*CANCL'
*=================================================================*
* Procedure Output *
*=================================================================*
OQSYSPRT E ImBack
O 'I''m Back'
OQSYSPRT E InPssr
O 'In PSSR'
OQSYSPRT E Cancelling
O 'Cancelling...'
Figure 117 (Part 3 of 3). Source for Registering a Condition Handler
If you want to try these procedures, follow these steps:
1. To create the procedure RPGHDLR, using the source shown in Figure 116 on
page 239, type:
CRTRPGMOD MODULE(MYLIB/RPGHDLR)
2. To create the procedure SHOWERR, using the source shown in Figure 117 on
page 242, type:
CRTRPGMOD MODULE(MYLIB/SHOWERR)
3. To create the program, ERRORTEST, type
CRTPGM PGM(MYLIB/ERRORTEST) MODULE(SHOWERR RPGHDLR)
4. To run the program ERRORTEST, type:
OVRPRTF FILE(QSYSPRT) SHARE(*YES)
CALL PGM(MYLIB/ERRORTEST)
The output is shown below:
|
HDLR: In Handler for SHOWERR
| HDLR: Handling...
| I'm Back
| HDLR: In Handler for SHOWERR
| HDLR: Percolating...
| In PSSR
| Cancelling...
Using Cancel Handlers
Cancel handlers provide an important function by allowing you to get control for
clean-up and recovery actions when call stack entries are terminated by something
other than a normal return. For example, you might want one to get control when a
procedure ends via a system request '2', or because an inquiry message was
answered with 'C' (Cancel).
The Register Call Stack Entry Termination User Exit Procedure (CEERTX) and the
Call Stack Entry Termination User Exit Procedure (CEEUTX) ILE bindable APIs
provide a way of dynamically registering a user-defined routine to be run when the
call stack entry for which it is registered is cancelled. Once registered, the cancel
244 ILE RPG for AS/400 Programmer's Guide