data: begin of lt_tab occurs 0,
bukrs type bukrs,
text type c,
amt type p,
end of lt_tab.
type-pools abap.
data gt_comp type abap_component_tab with header line.
perform get_column tables lt_tab
changing gt_comp[].
loop at gt_comp where type->type_kind = 'P'.
write:/ gt_comp-name.
endloop.
*&---------------------------------------------------------------------*
*& Form get_column
*&---------------------------------------------------------------------*
form get_column tables pt_tab
changing pt_comp.
data: lr_data type ref to data,
lr_desc type ref to cl_abap_structdescr.
create data lr_data like line of pt_tab.
lr_desc ?= cl_abap_structdescr=>describe_by_data_ref( lr_data ).
pt_comp = lr_desc->get_components( ).
endform. " get_column