Exception Handling within a Cycle-Main Procedure

When an exception occurs within a cycle-main procedure ILE RPG does the following:
  1. If an error indicator is present on the calculation specification and the exception is one that is expected for that operation:
    1. The indicator is set on
    2. The exception is handled
    3. Control resumes with the next ILE RPG operation.
  2. If an 'E' operation code extender is present on the calculation specification and the exception is one that is expected for that operation:
    1. The return values for the built-in funtions %STATUS and %ERROR are set.
      Note: %STATUS is set when any exception occurs even if the 'E' extender is not specified.
    2. The exception is handled
    3. Control resumes with the next ILE RPG operation.
  3. If no error indicator or 'E' extender is present and the code that generates the exception is in the MONITOR block of a MONITOR group, control will pass to the on-error section of the MONITOR group.
  4. If no error indicator or 'E' extender is present, no active MONITOR group could handle the exception, and
    • you have coded a *PSSR error subroutine and the exception is a program exception

      or

    • you have coded a INFSR error subroutine for the file and the exception is an I/O exception,

    then the exception will be handled and control will resume at the first statement of the error subroutine.

  5. If no error indicator, 'E' extender, or error subroutine is coded and no active MONITOR group could handle the exception, then the RPG default error handler is invoked.
    • If the exception is not a function check, then the exception will be percolated.
    • If the exception is a function check, then an inquiry message will be displayed. If the 'G' or 'R' option is chosen, the function check will be handled and control will resume at the appropriate point (*GETIN for 'G' or the same calculation specification that received the exception for 'R') in the procedure. Otherwise,the function check will be percolated and the procedure will be abnormally terminated.

See Unhandled Exceptions for a full description of the RPG default handler.


Feedback