Advertising:

Get column names of a structure: Difference between revisions

From SAP Knowledge Base
(Created page with "Kategorie:code_snippets <syntaxhighlight lang="abap" line start="1"> DATA columns TYPE if_fdt_doc_spreadsheet=>t_column. DATA(desc) = CAST cl_abap_structdescr( cl_abap_structdescr=>describe_by_data( struc_from_itab ) ). LOOP AT desc->get_components( ) ASSIGNING FIELD-SYMBOL(<c>). IF <c> IS ASSIGNED. IF <c>-type->kind = cl_abap_typedescr=>kind_elem. APPEND VALUE #( id = sy-tabix name...")
 
No edit summary
Line 1: Line 1:
[[Kategorie:code_snippets]]
[[category:code_snippets]]
<syntaxhighlight lang="abap" line start="1">
<syntaxhighlight lang="abap" line start="1">
  DATA columns        TYPE if_fdt_doc_spreadsheet=>t_column.
  DATA columns        TYPE if_fdt_doc_spreadsheet=>t_column.

Revision as of 15:23, 21 December 2024

 DATA columns         TYPE if_fdt_doc_spreadsheet=>t_column.
 DATA(desc) = CAST cl_abap_structdescr( cl_abap_structdescr=>describe_by_data( struc_from_itab ) ).
      LOOP AT desc->get_components( ) ASSIGNING FIELD-SYMBOL(<c>).
        IF <c> IS ASSIGNED.
          IF <c>-type->kind = cl_abap_typedescr=>kind_elem.
            APPEND VALUE #( id           = sy-tabix
                            name         = <c>-name
                            display_name = <c>-name
                            is_result    = abap_true
                            type         = <c>-type ) TO columns.
          ENDIF.
        ENDIF.
      ENDLOOP.
DATA _mt_output TYPE WB2_S_BVDETAIL_OUTPUT_TAB
DATA(lo_tdesc) = CAST cl_abap_tabledescr( cl_abap_tabledescr=>describe_by_data( _mt_output ) ).
DATA(lo_sdesc) = CAST cl_abap_structdescr( lo_tdesc->get_table_line_type( ) ).
rt_components = lo_sdesc->get_ddic_field_list( ).

This is a wiki created in the spare time of a private person working in the SAP ERP area. The aim is to collect knowledge for the own use. The wiki is maintained to the best of knowledge and belief.
All products shown, including in form of screenshots, belong to SAP SE. Their trademarks are, among others: SAP®,ABAP®,SAP Fiori®,SAP HANA®,SAP NetWeaver®,SAP® R/3®,SAP S/4HANA®,SAP S/4HANA® Cloud