IBM AS/400 Frozen Dessert Maker User Manual


 
Using Exception Handlers
Note: The same exception handling events described would apply to a procedure
call (CALLB operation) as well.
Example of Unhandled Function Check
The following scenario describes the events which occur when a function check
occurs in a main procedure and is not handled. This scenario has the following
assumptions:
1. There are two programs, PGM1 and PGM2, each containing a procedure,
PRC1 and PRC2 respectively.
2. PRC1 calls PGM2 dynamically and PRC2 receives control.
3. The CALL operation code in PRC1 does not have an error indicator coded.
4. No RPG exception handlers have been coded in PRC2. That is, there is no
error indicator coded and there is no *PSSR error subroutine.
5. PRC2 has a pointer address error.
When PGM1 calls PGM2, a pointer error occurs because the basing pointer is
defined as null. Consequently, MCH1306 is generated. A function check occurs
when PRC2 tries to percolate the exception past the control boundary. Figure 110
depicts this scenario and the events which occur.
Procedure PRC2
D FLD S 5A BASED(PTR)
C EVAL PTR=NULL
C EVAL FLD='ABCDE'
MCH3601 issued
Procedure PRC2
D FLD S 5A BASED(PTR)
C EVAL PTR=NULL
C EVAL FLD='ABCDE'
CPF9999 issued
Procedure PRC1
CALL PRC2
Procedure PRC1
CALL PRC2
RPG default Hdlr
RPG default Hdlr
RPG default Hdlr
RPG default Hdlr
Active Exception Handler List
Active Exception Handler List
Percolate
MCH3601
Percolate
CPF9999
PASS 1
PASS 2
Call Stack
Call Stack
Figure 110. Scenario for Unhandled Function Check
Chapter 12. Handling Exceptions 225