SAP REF TRANSF GLOBAL DATA - Guide
Get Example source ABAP code based on a different SAP table
Pass by Reference of Global Data
ABAP_BACKGROUND
In a local context you can normally directly access the
Therefore, if a more global data object is passed to a procedure by reference, access is granted there both through its name and the formal parameter.
ABAP_RULE
Do not use global data as actual parameters for formal parameters of procedures if you can change them in the procedure in another way, and the parameter is passed by reference.
ABAP_DETAILS
If a global data object that has also been passed by reference is changed in a procedure (
Global data is only supposed to be passed to formal parameters for which
ABAP_EXAMPLE_BAD
After the
PUBLIC SECTION.
METHODS
main.
PRIVATE SECTION.
DATA
attr TYPE p DECIMALS 2.
METHODS
do_something CHANGING c_value TYPE numeric.
ENDCLASS.
CLASS class IMPLEMENTATION.
METHOD main.
attr = '1.23'.
do_something( CHANGING c_value = attr ).
ENDMETHOD.
METHOD do_something.
...
c_value = floor( attr ).
...
c_value = c_value + attr.
...
ENDMETHOD.
ENDCLASS.
ABAP_EXAMPLE_END
ABAP_EXAMPLE_GOOD
If the pass by reference method in the method declaration of
METHODS
do_something CHANGING VALUE(c_value) TYPE numeric.
...
ABAP_EXAMPLE_END