Application Development 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: 

how do i get the fieldname of a component within a dynamic table ?

0 Kudos

Hi friends,

i have a question regarding the following bit of code i have:

DO.
      ASSIGN COMPONENT sy-index OF STRUCTURE <dyn_wa> TO <dyn_field>.
      IF sy-subrc <> 0.
         ...
      ELSE.
         ...
      ENDIF.
ENDDO.

I get the content of the field assigned to <dyn_field> but how do i get the name of the component ( in this case the fieldname ) ?.

Regards, i will give points immediately and generously for sure!

Clemens

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi,

By this code you may get some idea....

i_finaltab ---is internal table.

Include ole2incl.

data : det type ref to CL_ABAP_structDESCR.

det ?= cl_abap_typedescr=>describe_by_DATA( i_finaltab ).

loop at det->components into wa.

call method of sheet 'Cells' = cells

exporting

#1 = index.

set property of cells 'Value' = wa-name.

index = index + 1.

endloop.

Don't forget to reward if useful

1 REPLY 1

Former Member
0 Kudos

Hi,

By this code you may get some idea....

i_finaltab ---is internal table.

Include ole2incl.

data : det type ref to CL_ABAP_structDESCR.

det ?= cl_abap_typedescr=>describe_by_DATA( i_finaltab ).

loop at det->components into wa.

call method of sheet 'Cells' = cells

exporting

#1 = index.

set property of cells 'Value' = wa-name.

index = index + 1.

endloop.

Don't forget to reward if useful