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: 

Dynamic Fieldname assignment

Former Member
0 Kudos

Hi,

How to get the field name dynamically from an internal table.

For ex:

I need to assign some fields based on some condition, but i dont know which fields meet the condition.

Loop at it_pos.

Loop at it_fieldcat.

if it_fieldcat-no_out = ' '.

  • Now how to get the field name dynamically

    • it_display-(it_fieldcat-fieldname) = it_pos-(it_fieldcat-fieldname)*.

this code is giving error, what is the correct syntax for such assignments

Thanks,

Ravi K

1 ACCEPTED SOLUTION

Former Member
0 Kudos

HI,

Better way to do this is to use field symbols.

Use class cl_abap_structdescr to get the components of your structure and then use field symbols to compare values

ASSIGN COMPONENT <comp> OF STRUCTURE <your structure> TO <FS>.

Shruthi

2 REPLIES 2

Former Member
0 Kudos

u have to use fieldsymbol for this.

go to abap editor write fieldsymbols and press F1 .

u will get help for fieldsymbols.

Edited by: Suyog Haralikar on Jun 4, 2008 5:25 AM

Former Member
0 Kudos

HI,

Better way to do this is to use field symbols.

Use class cl_abap_structdescr to get the components of your structure and then use field symbols to compare values

ASSIGN COMPONENT <comp> OF STRUCTURE <your structure> TO <FS>.

Shruthi