‎2011 Feb 17 8:07 PM
Hi,
Probably a very simple question, but i was not able to find the answer (yet). Hopefully you can help me.
I have a data reference, which is a TYPE REF TO data
In some cases the reference can point to a table and in the other cases it points to a structure.
Now i want to know how i can identify the DATA reference if it is a table or structure?
Regards,
/Peter
In the expample below, how to i know LR_DATATAB is refering to a table and LR_DATASTRUC is refering to a structure?
====example===
REPORT zpval_test01.
TYPES ty_t_t001 TYPE STANDARD TABLE OF t001.
DATA lt_t001 TYPE STANDARD TABLE OF t001.
DATA ls_t001 LIKE LINE OF lt_t001.
DATA lr_datatab TYPE REF TO data.
DATA lr_datastruc TYPE REF TO data.
START-OF-SELECTION.
SELECT *
FROM t001
INTO TABLE lt_t001.
READ TABLE lt_t001 INTO ls_t001
INDEX 1.
CREATE DATA lr_datatab TYPE ty_t_t001.
GET REFERENCE OF lt_t001 INTO lr_datatab.
CREATE DATA lr_datastruc TYPE t001.
GET REFERENCE OF ls_t001 INTO lr_datastruc.
‎2011 Feb 17 10:26 PM
Hi,
You can see the example in [documentation|http://help.sap.com/saphelp_nw2004s/helpdata/en/fc/eb3145358411d1829f0000e829fbfe/frameset.htm]
‎2011 Feb 17 10:18 PM
You can use the RTTI classes to identify the type of reference. For example, using cl_abap_typedescr=>describe_by_data_ref, you would pass either data reference to the call. The received object is declared generally as TYPE REF TO cl_abap_typedescr, but the reference you get back is either an instance of class CL_ABAP_STRUCTDESCR or CL_ABAP_TABLEDESCR.
‎2011 Feb 17 10:26 PM
Hi,
You can see the example in [documentation|http://help.sap.com/saphelp_nw2004s/helpdata/en/fc/eb3145358411d1829f0000e829fbfe/frameset.htm]
‎2011 Feb 18 6:33 AM
Hi all,
DESCRIBE FIELD <l_tab> TYPE l_type. does the thing.
For a table TYPE = h and for a structure TYPE = u.
Thanks all,
Peter