IBM AS/400 Frozen Dessert Maker User Manual


 
*-----------------------------------------------------------------
* Define the cancel handler. The parameter is a pointer to the
* 'communication area', a message to be displayed.
*-----------------------------------------------------------------
P CanHdlr B
D CanHdlr PI
D pMsg *
*-----------------------------------------------------------------
* Define a field based on the input pointer pMsg.
*-----------------------------------------------------------------
D Msg S 20A BASED(pMsg)
*-----------------------------------------------------------------
* Display the message set by the procedure that enabled the
* handler.
*-----------------------------------------------------------------
C 'Cancel Hdlr 'DSPLY Msg
P CanHdlr E
Figure 118 (Part 4 of 4). Enabling and Coding a Cancel Handler for a Subprocedure
The following is the output from program CANHDLR. Note that the *PSSR of the
procedure SubProc is called three times but the cancel handler is only called twice
because it was disabled before the third error.
DSPLY Cancel Hdlr Divide by zero
DSPLY Subproc PSSR
DSPLY Cancel Hdlr String error
DSPLY Subproc PSSR
DSPLY Subproc PSSR
Figure 119. Output from CANHDLR program
Problems when ILE CL Monitors for Notify and Status Messages
If your ILE RPG procedure is called by an ILE CL procedure in the same activation
group, and the caller is monitoring for status or notify messages, then your ILE CL
caller may get control prematurely because of a notify or status message that the
ILE RPG procedure was trying to ignore.
For example, if the ILE RPG procedure writes a record to a printer file and the
actual printer file has a shorter record length that was declared in the RPG proce-
dure, notify message CPF4906 is sent to the RPG procedure. The RPG exception
handling percolates this message which causes the default reply of 'I' to ignore the
message. This should allow the output operation to continue normally, and the RPG
procedure should proceed to the next instruction.
However, when the ILE CL MONMSG gets control, control passes immediately to
the action for the MONMSG or the next statement in the ILE CL procedure.
Note: For this problem to occur, the procedure monitoring for the message does
not have to be the immediate caller of the RPG procedure.
This problem is most likely to occur with a MONMSG in an ILE CL caller, but it can
also occur with other ILE languages that can monitor for notify and status mes-
sages, including ILE RPG using ILE condition handlers enabled using CEEHDLR.
Chapter 12. Handling Exceptions 247