‎2021 Jun 18 2:28 PM
Hi Experts,
I am having confusion about How to use the Reference type in Data Element? and when we have to use this Reference type?
Thanks in Advance,
‎2021 Jun 18 2:39 PM
When you declare data into a program, you could use two syntax: TYPE or TYPE REF TO ..
You screenshot is like if you are using TYPE REF TO
Most of the time, it is used, when you need to reference an instance of a class.
‎2021 Jun 18 5:56 PM
‎2021 Jun 19 7:32 AM
TYPE and TYPE REF TO in report program level. but in DDIC 'TYPE REF TO' how can we use?. I am using a class name in a data element but activating the database table is throwing an error.

‎2021 Jun 19 1:51 PM
In programs you might have something like:
DATA a_line_of_t100 TYPE REF TO t100.
LOOP AT t100_Records REFERENCE INTO a_line_of_t100.
a_line_of_t100->text = to_upper( a_line_of_t100->text ).
ENDLOOP. You can define z_ref_to_a_line_of_t100 in the DBIC to be a reference to t100. Then you can use
DATA a_line_of_t100 TYPE z_ref_to_a_line_of_t100.I use references to pass around data without copying it.
‎2021 Jun 20 7:06 AM
You cannot use a Reference Type (TYPE REF TO) in a Database Table ! If you want to store a reference, one solution is to make the reference serializable (IF_SERIALIZABLE_OBJECT in its class), define a RAWSTRING column, and serialize the reference to the database column (CALL TRANSFORMATION), and deserialize it when you read it later (CALL TRANSFORMATION in the other direction). But you have other more simple workarounds.
‎2021 Jun 20 8:30 AM
Ref Types itself doesn't contains data. It's only a pointer to a data object or class instance.
It's reference to the memory of a dataobject.
Therefore, it doesn't make sense to use reference types in database tables, because you want to persist data.
You can use references to modify variable (like an internal table) values indirectly.
For example :
loop at it_data references into r_data.
r_data->field1 = "new value".
endloop.
https://help.sap.com/doc/abapdocu_750_index_htm/7.50/en-US/abaploop_at_itab_result.htm
or similar to
loop at it_data assigning field-symbol(<wa_data>).
<wa_data>-field1 = "new value".
endloop
in both cases you modify the content in the table at the current row position.
For further information, please check the ABAP Help
https://help.sap.com/doc/abapdocu_750_index_htm/7.50/en-US/abendata_references.htm