SAP REF TRANSF OUTPUT PARAM - Guide
Get Example source ABAP code based on a different SAP table
Pass by Reference for Output Parameters
ABAP_BACKGROUND
When parameters are passed to a procedure by reference, this procedure directly uses the data object that has been passed as a parameter. Its value is consequently determined by the calling program of the procedure. Particular notice must be made of this behavior for
ABAP_RULE
Do not evaluate
ABAP_DETAILS
The value of an output parameter that has been passed by reference is undefined from the perspective of the procedure, since cannot be evaluated within the procedure in a useful manner. Therefore, no assumptions can be made regarding the content of the parameter until the first value has been assigned to it.
If a parameter like this is an internal table or a string, a simple write is not sufficient. First, an initialization must be implemented. For example, if new lines are to be inserted in an internal table that is supposed to be produced by reference, its current content needs to be deleted first. Pass by reference means that it cannot be guaranteed that the table is actually empty when the procedure is started. The same applies to strings that are filled using concatenation operations within the procedure.
Latest notes:
If the described properties are to be exploited for writable parameters that have been passed by reference in a procedure (
ABAP_HINT_END
Exception
Strictly speaking, optional output parameters that have been passed by reference must be initialized only if the parameter is bound to an actual parameter when called. This can be determined using the
Example ABAP Coding
The following source code shows how an internal table that, for performance reasons, is implemented by reference is returned. For this reason, it cannot be declared as a
PUBLIC SECTION.
CLASS-METHODS get_some_table
EXPORTING e_some_table TYPE table_type.
ENDCLASS.
CLASS class IMPLEMENTATION.
METHOD get_some_table.
DATA new_line LIKE LINE OF e_some_table.
CLEAR e_some_table.
...
INSERT new_line INTO TABLE e_some_table.
...
ENDMETHOD.
ENDCLASS.
ABAP_EXAMPLE_END