SAP Tutorials Blog


 


Using the instance operator NEW and CREATE DATA statements, you can create anonymous data objects, such as anonymous structures. The NEW addition of the INTO clause of an ABAP SQL SELECT statement also creates an anonymous data object. As outlined below, you can access the components or the entire data objects by dereferencing. For more information, refer to the Dynamic Programming and Constructor Expressions cheat sheets.


"Without assigning component values in the parentheses, the anonymous

"structure is initial.

DATA(struc_ref_a) = NEW struc_type( ).


DATA struc_ref_b TYPE REF TO DATA.

struc_ref_b = NEW struc_type( ).


"Multiple syntax options are available for CREATE DATA

"statements. See the cheat sheets mentioned.

CREATE DATA struc_ref_b TYPE struc_type.


DATA struc_ref_c TYPE REF TO struc_type.

"Implicit data type definition

CREATE DATA struc_ref_c.


"NEW addition of the INTO clause of an ABAP SQL SELECT statement

SELECT SINGLE carrid, carrname

 FROM zdemo_abap_carr

 WHERE carrid = char`LH`

 INTO NEW @DATA(struc_ref_d).


Serkan AKKAVAK

Computer Engineer BSc

Head of SAP & Software Department

Contact : serkurumsal@yandex.com