How to find column names in a statically defined internal table
Here is the sample code with which you can find out the fields and other properties of your statically defined internal table dynamically.
Here is the sample code with which you can find out the fields and other properties of your statically defined internal table dynamically. Code tested in 4.7EE.
REPORT ZTEST.
TYPE-POOLS : abap.
DATA: BEGIN OF tabl occurs 0,
mandt TYPE mara-mandt,
matnr TYPE mara-matnr,
ersda TYPE mara-ersda,
ernam TYPE mara-ernam,
laeda TYPE mara-laeda,
aenam TYPE mara-aenam,
vpsta TYPE mara-vpsta,
pstat TYPE mara-pstat,
lvorm TYPE mara-lvorm,
mtart TYPE mara-mtart,
mbrsh TYPE mara-mbrsh,
END OF tabl.
DATA : it_details TYPE abap_compdescr_tab,
wa_comp TYPE abap_compdescr.
DATA : ref_descr TYPE REF TO cl_abap_structdescr.
ref_descr ?= cl_abap_typedescr=>describe_by_data( tabl ).
it_details[] = ref_descr->components[].
loop at it_details into wa_comp.
write:/ wa_comp.
endloop.