IBM AS/400 Frozen Dessert Maker User Manual


 
This section provides some examples of how to use each of these RPG constructs.
The
ILE RPG for AS/400 Reference
provides more information on the *PSSR and
INFSR error subroutines, on the EXSR operation code, and on the INFDS and
PSDS data structures.
Specifying Error Indicators or the 'E' Operation Code Extender
Operation codes that allow an error indicator also allow the 'E' operation code
extender. The CALLP operation also allows the 'E' extender although it does not
allow an error indicator. This provides two ILE RPG error handling methods that are
essentially the same. Either an error indicator or the 'E' extender can be used to
handle the exception for the same operation code, not both.
Note: If an error indicator or and 'E' extender is coded on an operation, but the
error which occurs is not related to the operation (for example, an array-
index error on a CHAIN operation), any error indicator or 'E' extender would
be ignored. The error would be treated like any other program error.
To enable the RPG error indicator handler, you specify an error indicator in posi-
tions 73 and 74 for the operation codes listed in Table 15 on page 228 (except for
CALLP). If an exception occurs on the operation, the indicator is set on, the appro-
priate data structure (PSDS or INFDS) is updated, and control returns to the next
sequential instruction. You can then test the indicator to determine what action to
take.
To enable the 'E' operation code extender handler, you specify an 'E' (or 'e') with
any of the operation codes in Table 15 on page 228. Coding the 'E' extender
affects the value returned by the built-in functions %ERROR and %STATUS for
exceptions. Before the operation begins, the value returned by these built-in func-
tions is set to zero. If an exception occurs on the operation, the return values for
these built-in functions are updated accordingly, the appropriate data structure
(PSDS or INFDS) is updated, and control returns to the next sequential instruction.
You can then use these built-in functions to test the returned values and determine
what action to take.
Chapter 12. Handling Exceptions 227