Structure to Table, Alanları tablo şeklinde gösterme
Bir structure`daki tüm alanları tabloya çeviren kod
types: begin of ty_field_table ,
fieldname type fieldname,
REPTEXT type REPTEXT,
value type text100,
END OF ty_field_table.
types: tty_field_table type STANDARD TABLE OF ty_field_table.
data: ls_any_structure type ZSD_S_***********.
data: lt_popuptable type tty_field_table .
perform f_structure_to_table USING ls_any_structure
space
CHANGING lt_popuptable .
space
CHANGING lt_popuptable .
form f_structure_to_table USING prm_structure type ANY
prm_refresh type xfeld
CHANGING cht_table type tty_field_table .
data lr_structdescr type ref to cl_abap_structdescr.
data l_component type abap_compdescr .
data: lt_fields type DDFIELDS.
data: ls_field type DFIES.
data: ls_row type ty_field_table.
if prm_refresh = `X`.
refresh cht_table.
endif.
FIELD-SYMBOLS: < fs_value > type ANY .
lr_structdescr ?= cl_abap_typedescr=>describe_by_data( prm_structure ).
lt_fields = lr_structdescr->GET_DDIC_FIELD_LIST( ) .
*
LOOP AT lt_fields INTO ls_field.
ls_row-fieldname = ls_field-fieldname.
ls_row-REPTEXT = ls_field-REPTEXT.
if < fs_value > is ASSIGNED. UNASSIGN < fs_value >. endif.
ASSIGN component ls_field-fieldname OF STRUCTURE prm_structure TO < fs_value >.
if < fs_value > is ASSIGNED.
ls_row-value = < fs_value >.
endif.
append ls_row to cht_table.
endloop.
ENDFORM.
Örnek Çıktı: