IBM AS/400 Frozen Dessert Maker User Manual


 
Returning from a Called Program or Procedure
Multiple PLISTs can appear in a procedure. However, only one *ENTRY PLIST can
be specified, and only in the main procedure.
For examples of the PLIST operation see Figure 47 on page 105 and Figure 116
on page 239.
Returning from a Called Program or Procedure
When a program or procedure returns, its call stack entry is removed from the call
stack. (If it is a program, the program entry procedure is removed as well.) A proce-
dure ends abnormally when something outside the procedure ends its invocation.
For example, this would occur if an ILE RPG procedure X calls another procedure
(such as a CL procedure) that issues an escape message directly to the procedure
calling X. This would also occur if the procedure gets an exception that is handled
by an exception handler (a *PSSR or error indicator) of a procedure further up the
call stack.
Because of the cycle code associated with main procedures, their return is also
associated with certain termination routines. This section discusses the different
ways that main procedures and subprocedures can return, and the actions that
occur with each.
Returning from a Main Procedure
A return from a main procedure causes the following to occur:
If LR is on, files are closed and other resources are freed.
The procedure's call stack entry is removed from the call stack.
If the procedure was called by the program entry procedure, then that program
entry procedure is also removed from the call stack.
A main procedure returns control to the calling procedure in one of the following
ways:
With a normal end
With an abnormal end
Without an end.
A description of the ways to return from a called main procedure follows.
For a detailed description of where the LR, H1 through H9, and RT indicators are
tested in the RPG program cycle, see the section on the RPG program cycle in the
ILE RPG for AS/400 Reference
.
Normal End
A main procedure ends normally and control returns to the calling procedure when
the LR indicator is on and the H1 through H9 indicators are not on. The LR indi-
cator can be set on:
implicitly, as when the last record is processed from a primary or secondary file
during the RPG program cycle
explicitly, as when you set LR on.
A main procedure also ends normally if:
152 ILE RPG for AS/400 Programmer's Guide