Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Getting component name

Former Member
0 Likes
990

Guys,

I want to find the component names of my dynamic table

ASSIGN COMPONENT sy-index

OF STRUCTURE <wa_table> TO <dyn_field>.

I know there are couple of threads but they are confusing, I tried using one of the method

ref_table_des ?=

cl_abap_typedescr=>describe_by_name( p_data = <t_dyn_table> ).

idetails[] = ref_table_des->components[].

but then I get an error as formal parameter p_data does not exist.

3 REPLIES 3
Read only

Former Member
0 Likes
886

Check this Example.

DATA : sflighttype type ref to cl_abap_structdescr,
      comp_tab    type cl_abap_structdescr=>component_table.
field-symbols: <wa_comp> like line of comp_tab.
sflighttype ?= cl_abap_typedescr=>describe_by_name('SFLIGHT').
comp_tab = sflighttype->get_components( ).

LOOP AT comp_tab ASSIGNING <wa_comp>.
  write : / <wa_comp>-name.
ENDLOOP.

In your case.

it should be

ref_table_des ?=
cl_abap_typedescr=>describe_by_name( <t_dyn_table> ).

Read only

0 Likes
886

when i do that i get this error...

The parameter p_name does not have correct type.

The program tried to pass an actual parameter to formal parameter

"P_NAME" of method "DESCRIBE_BY_NAME" of class "CL_ABAP_TYPEDESCR" that did not

have the type

C or STRING at runtime.

Read only

0 Likes
886

I got it I should have changed the method type. Use describe by data.