Skip to Content
0
Former Member
Nov 22, 2012 at 08:13 AM

How to get the components of table deep structure

511 Views

Hi experts,

Am not able to get the all components of mara table , why bcoz in mara table they included another structure.

Am able to disply only 2 fields only.

plz have a look below code :

data: text type string,
it_table type table of mara,
wa_table like line of it_table,
lt_comp type ABAP_COMPONENT_TAB,
ls_comp like line of lt_comp.
data: lo_ref type ref to CL_ABAP_STRUCTDESCR,
lo_cast type ref to CX_SY_MOVE_CAST_ERROR.

try.
lo_ref ?= CL_ABAP_TYPEDESCR=>DESCRIBE_BY_DATA( wa_table ).
catch CX_SY_MOVE_CAST_ERROR into lo_cast.
text = lo_cast->get_text( ).
endtry.
lt_comp = lo_ref->get_components( ).
loop at lt_comp into ls_comp.
write:/ ls_comp-name.
clear: ls_comp.
endloop.