Quantcast
Channel: SCN: Message List - ABAP Connectivity
Viewing all articles
Browse latest Browse all 3125

Re: Field names of internal table

$
0
0

Hello Alita,

 

Please, adjust the call of GET_COMPONENT_LIST by passing not the internal table for an import parameter FIELDNAME, but the char-like variable or literal holding the name of the internal table for which you would like to retrieve its components. The simplest way here would be to put internal table's name in quatation marks:

 

CALL FUNCTION 'GET_COMPONENT_LIST'

   EXPORTING

     program    = sy-repid

     fieldname  = 'itab'

   TABLES

     components = lt_comp.

 

A more advanced technique that can be utilized for retrieving a list of components of the internal table at runtime would be usage of ABAP Runtime Type Services. Here is a sample source code that illustrates their usage for your case:

 

DATA:

  " table for which list of components should be retrieved

  lt_data_original TYPE TABLE OF <...> ,

  lo_descr      TYPE REF TO cl_abap_tabledescr,

  lo_type       TYPE REF TO cl_abap_datadescr,

  lo_struct     TYPE REF TO cl_abap_structdescr,

  " table which holds enumeration of components

  lt_components TYPE cl_abap_structdescr=>component_table.

 

 

lo_descr ?= cl_abap_typedescr=>describe_by_data( lt_data_original ).

lo_type = lo_descr->get_table_line_type( ).

lo_struct ?= cl_abap_typedescr=>describe_by_name( lo_type->absolute_name ).

lt_components = lo_struct->get_components( ).

 

Regards,

Vadim


Viewing all articles
Browse latest Browse all 3125

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>