ILE RPG Language Reference
Some examples of file exception/errors are: undefined record type,
an error in trigger program, an I/O operation to a closed file, a
device error, and an array/table load sequence error. They can be
handled in one of the following ways:
- The operation code extender 'E' can be specified. When specified,
before the operation begins, this extender sets the %ERROR and %STATUS
built-in functions to return zero. If an exception/error occurs during
the operation, then after the operation %ERROR returns '1' and %STATUS
returns the file status. The optional file information data structure
is updated with the exception/error information. You can determine
the action to be taken by testing %ERROR and %STATUS.
- An indicator can be specified in positions 73 and 74 of the calculation
specifications for an operation code. This indicator is set on if
an exception/error occurs during the processing of the specified operation.
The optional file information data structure is
updated with the exception/error information. You can determine the
action to be taken by testing the indicator.
- ON-ERROR groups can be used to handle errors for statements
processed within a MONITOR block. If an error occurs when a statement
is processed, control passes to the appropriate ON-ERROR group.
- You can create a user-defined ILE exception handler that will
take control when an exception occurs. For more information, see IBM® Rational® Development Studio for i: ILE RPG Programmer's Guide.
- A file exception/error subroutine can
be specified for a global file in a cycle module. The subroutine
is defined by the INFSR keyword on a file description specification
with the name of the subroutine that is to receive the control. Information
regarding the file exception/error is made available through a file
information data structure that is specified with the INFDS keyword
on the file description specification. You can also use the %STATUS
built-in function, which returns the most recent value set for the
program or file status. If a file is specified, %STATUS returns the
value contained in the INFDS *STATUS field for the specified file.
- If the indicator, 'E' extender, MONITOR block, or
file exception/error subroutine is not present, any file exception/errors
are handled by the RPG IV default error handler.
[ Top of Page | Previous Page | Next Page | Contents |
Index ]