Structure to Table, Alanları tablo şeklinde gösterme

 Bir structure`daki tüm alanları tabloya çeviren kod


typesbegin of ty_field_table ,
          fieldname     type fieldname,
          REPTEXT    type REPTEXT,
          value         type text100,
       END OF ty_field_table.
typestty_field_table type STANDARD TABLE OF ty_field_table.

data: ls_any_structure type ZSD_S_***********.
datalt_popuptable type tty_field_table .
        perform f_structure_to_table  USING    ls_any_structure
                                    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 .
      datalt_fields type DDFIELDS.
      datals_field type DFIES.
      datals_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_dataprm_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 ASSIGNEDUNASSIGN < 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ı: