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

Dynamic Fieldname assignment

Former Member
0 Likes
435

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
Read only

Former Member
0 Likes
413

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
Read only

Former Member
0 Likes
413

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

Read only

Former Member
0 Likes
414

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