Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Get Components

hi everyone,

I know how i can get components information from transparent tables or any structure in the data dictionary.

But, if i have just a internal table, how can i get components table?

E.g:

data:

types: BEGIN OF st_table,

matnr type matnr,

name1 type name1,

END OF st_table.

data: i_table TYPE TABLE OF st_table.

DATA: l_struc TYPE REF TO cl_abap_structdescr.

DATA: lt_comp TYPE cl_abap_structdescr=>component_table.

DATA: ls_comp LIKE LINE OF lt_comp.

l_struc ?= cl_abap_typedescr=>describe_by_name( itab-tabname ).

lt_comp = l_struc->get_components( ).

      • Does not work out

i've already try the following ones:

DESCRIBE_BY_DATA

DESCRIBE_BY_NAME

DESCRIBE_BY_OBJECT_REF

DESCRIBE_BY_DATA_REF

Any idea?

Alexandre

Tags:
replied

Check this, you get all the info you need in ls_components

type-pools abap.

types: begin of ty_est,
firstname type c,
second type i,
third type d,
end of ty_est.
DATA: ls_components TYPE ABAP_COMPDESCR_TAB,
      wa_components like line of ls_components.
DATA: lo_strucdescr TYPE REF TO cl_abap_structdescr.
data: itab type table of ty_est with header line.


lo_strucdescr ?= cl_abap_typedescr=>describe_by_data( itab ).
ls_components = lo_strucdescr->components.

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question