Get Example source ABAP code based on a different SAP table
ID RETURN • RETURN ABAP Statement
RETURN> Short Reference >
ABAP_SYNTAX RETURN $[expr$].>
ABAP Addition ... $[expr$]>
What does it do? This statement immediately terminates the current processing block. It can appear at any point in a processing block> and terminates this block regardless of the statement block or control structure in which the statement appears. After the processing block has been exited, the runtime framework behaves as when the processing block is exited in a regular way> BEGIN_SECTION VERSION 5 OUT , with the exception of LOAD-OF-PROGRAM> > and the reporting event blocks> START-OF-SELECTION> and GET> END_SECTION VERSION 5 OUT . In particular, the output parameters of procedures are passed on to the bound actual parameters. BEGIN_SECTION VERSION 5 OUT
The event block LOAD-OF-PROGRAM> cannot be exited using RETURN >.
After the reporting event block START-OF-SELECTION> is terminated using RETURN>, the runtime framework does not raise any more reporting events and instead calls the list processor directly to display the basic list.
After the reporting event block GET> is terminated using RETURN>, 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. END_SECTION VERSION 5 OUT
ABAP_PGL Only use RETURN> to exit procedures > ABAP_PGL_END
Latest notes:
The statement RETURN> is generally intended for early but proper returns from processing blocks.
Especially in functional methods>, the actual value of the return value> is passed to the caller. NON_V5_HINTS
Since RETURN> behaves differently in GET>> events than when the event block is terminated as usual, the statement REJECT >> should be used there, which was designed especially for this purpose. ABAP_HINT_END
ABAP_EXAMPLE_VX5 Exit of the method show_list> using RETURN> if one of the formal parameters required (structure> or data_tab>) is initial. ABEXA 01697 ABAP_EXAMPLE_END
ABAP Addition
What does it do? In functional methods>, that is methods with one return value> r>, a data object or an expression expr> can be placed behind RETURN> where expr > is a general expression position >. The statement RETURN expr.> acts as a short form of the statements: r = expr. RETURN.> That means:
The result of the expression expr> is passed as the return value r> of the method to the caller.
The result of the expression expr> must be convertible> to the return value r> of the method.
For expr>, a constructor expression> with the specification #> for the type can be used. Then the type is inferred from the return value r>.
Latest notes:
It is possible to write RETURN r.> where r> is the return value. In this case, the assignment r = r> is skipped internally.
If RETURN> is the last statement in front of ENDMETHOD>, it is skipped internally and RETURN expr> works in the same way as r = expr>.
In any other context than a functional method, the RETURN> statement has no addition. NON_V5_HINTS ABAP_HINT_END
ABAP_EXAMPLE_VX5 A conditional iteration> with FOR> is used behind RETURN> to fill a tabular return value. In case of an error (overflow), the exception is caught and an empty table is constructed behind RETURN>. ABEXA 01746 ABAP_EXAMPLE_END