SAP Tutorials Blog


 


"Data references

"Declaring data object and assign value

DATA num TYPE i VALUE 5.


"Declaring data reference variable

DATA dref_a TYPE REF TO i.


"Getting references

dref_a = REF #( num ).


"Inline declaration

DATA(dref_b) = REF #( `hallo` ).

"Inline declaration and explicit type specification

DATA(dref_c) = REF abap_bool( 'X' ).


"Specifying table expressions as arguments. The example code includes

"additions to avoid an exception if table lines are not found.

DATA int_tab TYPE TABLE OF i WITH EMPTY KEY.

int_tab = VALUE #( ( 1 ) ( 2 ) ( 3 ) ).

DATA(dref_d) = REF #( int_tab[ 2 ] ).

DATA(dref_e) = REF #( int_tab[ 6 ] OPTIONAL ). "Initial reference variable

DATA(dref_f) = REF #( int_tab[ 7 ] DEFAULT NEW #( 123 ) ). "Providing a default value


"Object references

DATA(oref_a) = NEW zcl_demo_abap_objects( ).

DATA(oref_b) = REF #( oref_a ).



Serkan AKKAVAK

Computer Engineer BSc

SAP Department Manager

Contact : serkurumsal@yandex.com