11-22-2012 8:13 AM
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.
11-22-2012 9:42 AM
Change it as below.
data:tab type table of mara.
data:l_ref type ref to cl_abap_tabledescr,
l_dref type ref to cl_abap_structdescr,
text type string,
lo_cast type ref to CX_SY_MOVE_CAST_ERROR..
data wa type abap_compdescr.
try.
l_ref ?= cl_abap_typedescr=>describe_by_data( tab ).
l_dref ?= l_ref->get_table_line_type( ).
loop at l_dref->components into wa.
write 😕 wa-name.
endloop.
catch cx_sy_move_cast_error into lo_cast.
text = lo_cast->get_text( ).
endtry.
11-22-2012 9:42 AM
Change it as below.
data:tab type table of mara.
data:l_ref type ref to cl_abap_tabledescr,
l_dref type ref to cl_abap_structdescr,
text type string,
lo_cast type ref to CX_SY_MOVE_CAST_ERROR..
data wa type abap_compdescr.
try.
l_ref ?= cl_abap_typedescr=>describe_by_data( tab ).
l_dref ?= l_ref->get_table_line_type( ).
loop at l_dref->components into wa.
write 😕 wa-name.
endloop.
catch cx_sy_move_cast_error into lo_cast.
text = lo_cast->get_text( ).
endtry.