ABAP Keyword Documentation → ABAP - Reference → Calling and leaving program units → Exiting Program Units → Exiting Processing Blocks
RETURN
Other versions: 7.31 | 7.40 | 7.54
Syntax
RETURN.
Effect
This statement ends the current processing block immediately. It can appear at any point in a processing block and ends this block irrespective of the statement block or control structure in which the block appears.
After the processing block is exited, the runtime environment responds in the same way as when the
processing block is exited
in a regular way (with the exception of LOAD-OF-PROGRAM
and the
reporting event blocks
START-OF-SELECTION
and GET
). In particular, the output parameters of procedures are passed on to the bound actual parameters.
-
You cannot exit the
LOAD-OF-PROGRAM
event block usingRETURN
. -
After the reporting event block
START-OF-SELECTION
is exited using RETURN, the runtime environment does not trigger any more reporting events; instead, it calls the list processor directly to display the basic list. -
After the reporting event block
GET
is exited usingRETURN
, subordinate nodes in the hierarchical structure of the linked logical database are no longer processed. The logical database reads the next line of the current node or next higher node, if it has reached the end of the hierarchy level.
Programming Guideline
Only use RETURN
to exit procedures
Note
The RETURN
statement is provided for exiting processing blocks early but
correctly. However, since RETURN
behaves differently in
GET
events than when the event block is exited as usual, you should instead
use the REJECT
statement there, which has been designed especially for this purpose.
Example
Leave the method show_list
with RETURN
if one of the formal parameters required
(structure
or data_tab
) is initial.
"IMPORTING structure TYPE c
" data_tab TYPE ANY TABLE.
DATA alv_list TYPE REF TO cl_gui_alv_grid.
IF structure IS INITIAL OR
data_tab IS INITIAL.
RETURN.
ENDIF.
CREATE OBJECT alv_list
EXPORTING i_parent = cl_gui_container=>screen0.
alv_list->set_table_for_first_display(
EXPORTING i_structure_name = structure
CHANGING it_outtab = data_tab ).
CALL SCREEN 100.
ENDMETHOD.