Showing results for 
Search instead for 
Did you mean: 

Dynamically assign field value of one structure as a field name of another structure

0 Kudos

Dear ABAPers,

I have an internal table/structure X (extract from Custom table ) with several fields. One of the field value of internal table/structure X is a field name of another internal table/structure Y ( extract of another custom table )

Now i need to pick the field of internal table X, perform some logic to get a value to that field and pass both the field name and field value to internal table Y..

Ex :

1. Internal table X derived from Custom table

Int Tab X :

Field 1 - Material

Field 2 - Qty

Field 3 - Value

Do some processing to get the value of "Field2" and pass the values to Internal table Y as shown below ( expected output)

Int Tab Y :

Material - XYZ

Qty - 100

Value - 10

Tried Field symbols but unable to find solution...

Need help on this logic please.
Thanks in advance...

0 Kudos

Unfortunately not able to interpret your information properly. Please provide a small self-contained program that does the same operations based on some constant table data.

0 Kudos

Sorry if my above post was confusing....

Please ignore my earlier post...

I have 3 internal tables/structures. One structure has the field name , another structure has the mapping of field name from structure X and the corresponding field value . Both the field name from structure X and and field value from structure Z should be passed on to another structure Y as an output. That's my basic requirement.

Below mentioned screenshot is my example,

With reference to the below screenshot,

First Structure ( Int Tab X) has Field names mapping

Second structure ( Int Tab Z) has Field values

Third structure ( Int Tab Y) is the expected output

Hope i'm clear ....

Any help on this would be appreciated...

0 Kudos

This is exactly what the responses you have already got, can be applied to. Just read them and adopt to your case.


Accepted Solutions (0)

Answers (3)

Answers (3)

Active Contributor

To work with a generic structure (whatever it comes from parameters, field symbols, dereferencements), use this:


It has been answered a lot in the forum, so I won't explain again, but maybe someone will search for you and copy an existing answer. I think there is also a blog post about working with generic data objects.

To work with an internal table, there's no complexity:

LOOP AT <itab> ...

except if you want to search one line (you need a minimal ABAP release):

itab[ ('COMPNAME') = value ]
0 Kudos

Not sure if I understand what you mean (after reading the beginning of your post I thought I understood, but after reading your "example" - I don't).

If 'Qty' is a value of field FIELD_2 in your table INT_TAB_X - and you want to used it to access field QTY of table INT_TAB_Y, then:

a. you need the fieldname in upper case, that is: 'QTY', not 'Qty';

b. then you can use the following statement:

assign component INT_TAB_X-FIELD_2 of structure INT_TAB_Y to <field_symbol>.

(assuming here that both your tables INT_TAB_X and INT_TAB_Y are declared with header lines).

Check F1 help on "assign component ... of structure ..." for more details.


Active Contributor
0 Kudos

It seems to me this should work with Field-symbols. Check the reports