Skip to Content
0
Former Member
Oct 08, 2008 at 01:04 PM

get fieldname of dynamic structure by index

439 Views

Hello all,

how can i get the fieldname of a dynamic structure for example in a loop?

It is not really a problem but i am interested in an other solution.

Short example:

I create a dynamic structure and table of t001 named <t_table> and <w_struc>.

loop at <t_table> assigning <w_struc>.

do.

assign component sy-index of structure <w_table> to <field>.

  • now i want to know when i have access to 'PERIV', is index 10 in T001

  • i know 3 possibilities to get the name:

  • 1: read table DD03L with tablename and index (=>low performance)

  • 2: assign component 'PERIV' of structure <w_table> to <field>.

  • 3: read itab lt_components with index (method lt_components = lref_struct_descr->get_components( ). )

  • why i can't get the name direct from the reference lref_struct_descr like

lref_struct_descr->get_fieldname( sy-index )? This information has to be known at runtime too, i think?

enddo.

endloop.