Example of Unhandled Function Check

The following scenario describes the events which occur when a function check occurs in a cycle-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, no active MONITOR group, and 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 1 depicts this scenario and the events which occur.

Figure 1. Scenario for Unhandled Function Check
The following then occurs:
  1. Since there are no error handlers in PRC2, PRC2 cannot handle the function check, and so it is unhandled.
  2. Since it is a function check, an inquiry message is issued describing the originating condition.
  3. Depending on the response to the inquiry message, PRC2 may be terminated and the exception percolated to PRC1 (response is 'C') or processing may continue in PRC2 (response is 'G').