IBM AS/400 Frozen Dessert Maker User Manual


 
Returning from a Called Program or Procedure
The RETURN operation (with a blank factor 2) is processed, the H1 through H9
indicators are not on, and the LR indicator is on.
The RT indicator is on, the H1 through H9 indicators are not on, and the LR
indicator is on.
When a main procedure ends normally, the following occurs:
The Factor-2-to-Result-field move of a *ENTRY PARM operation is performed.
All arrays and tables with a 'To file name' specified on the Definition specifica-
tions, and all locked data area data structures are written out.
Any data areas locked by the procedure are unlocked.
All files that are open are closed.
A return code is set to indicate to the caller that the procedure has ended
normally, and control then returns to the caller.
On the next call to the main procedure, with the exception of exported variables, a
fresh copy is available for processing. (Exported variables are initialized only once,
when the program is first activated in an activation group. They retain their last
assigned value on a new call, even if LR was on for the previous call. If you want
to re-initialize them, you have to reset them manually.)
TIP
If you are accustomed to ending with LR on to cause storage to be released,
and you are running in a named (persistent) activation group, you may want to
consider returning without an end. The reasons are:
The storage is not freed until the activation group ends so there is no
storage advantage to ending with LR on.
Call performance is improved if the program is not re-initialized for each
call.
You would only want to do this if you did not need your program re-initialized
each time.
Abnormal End
A main procedure ends abnormally and control returns to the calling procedure
when one of the following occurs:
The cancel option is taken when an ILE RPG inquiry message is issued.
An ENDSR *CANCL operation in a *PSSR or INFSR error subroutine is proc-
essed. (For further information on the *CANCL return point for the *PSSR and
INFSR error subroutines, see “Specifying a Return Point in the ENDSR
Operation” on page 237).
An H1 through H9 indicator is on when a RETURN operation (with a blank
factor 2) is processed.
An H1 through H9 indicator is on when last record (LR) processing occurs in
the RPG cycle.
When a main procedure ends abnormally, the following occurs:
Chapter 10. Calling Programs and Procedures 153