ADELIA |
|
SADELIA |
|
|
(I/B) |
|
(B) (S) |
|
|
Warning: This instruction is only compatible with the Adelia version generating RPG, and with SADELIA programs.
Section for use
All
Syntax
RETURN
Description
On AS/400, this instruction is used to exit a called program.
Therefore the called program remains in the central memory and it remains in the list of active programs. The static memory is occupied and the work fields are still recognized by the system when executed at a later time.
Additionally, the files opened by the called program remain open.
In order to unload the program from memory and free its associated resources (open files), you can call the program again and close it using the TERMINATE instruction.
The other instruction that can be used to exit a program is TERMINATE.
With ADELIA programs, the program exit mode can be specified with TERMINATE in the same way as with RETURN during the program generation, (RT or LR generation options).
Warning:
- With ADELIA programs, some display problems may occur when using this instruction in a window program. In that case, you must explicitly handle the opening and closing of the screen file.
- In a SADELIA program generated for a platform other than the AS/400, a RETURN instruction placed in the INIT_PGM paragraph or a directly-called public procedure will have the same effect as the TERMINATE instruction; otherwise it has the same effect as the LEAVE instruction.
Example
* (PROGRAM ORDER_ENTRY) |
CALL CUST_WINDOW W_CUST_NAME W_CUST_CODE W_RETURN_CODE |
IF W_RETURN_CODE = 'T' |
ZZ_CUST_CODE = W_CUST_CODE |
ZZ_CUST_NAME = W_CUST_NAME |
END |
* (PROGRAM CUST_WINDOW) |
RECEIVE R_NAME R_CUSTOMER_CODE R_RETURN_CODE |
R_RETURN_CODE = *BLANK |
PROCESS 01 |
TRANSACTION 01 |
IF *F03 |
R_RETURN_CODE = 'T' |
TERMINATE |
* frees resources of this program |
* returns to ORDER_ENTRY |
END |
IF *F12 |
R_RETURN_CODE = 'R' |
RETURN |
* returns to ORDER_ENTRY |
* without freeing CUST_WINDOW resources |
END |