‎2008 Oct 31 7:06 PM
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.
‎2008 Oct 31 7:31 PM
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> ).
‎2008 Oct 31 8:18 PM
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.
‎2008 Oct 31 8:31 PM
I got it I should have changed the method type. Use describe by data.