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

Code to equate table value to work area field name

PankajVPatil
Participant
0 Likes
647

Hello Experts,

How to match a certain value fetched from table to the internal table field.

For instance: transparent table has a column containing values as

AMOUNT

QUANTITY

there is another work area structure associated with different internal table consisting of amount and quantity fields.

Now depending on whether the record from transparent table has fetched AMOUNT or QUANTITY, i have to read either the amount or quantity value from the work area.

Can any one please suggest a technique to do it?

Thanks,

Pankaj

1 ACCEPTED SOLUTION
Read only

MarcinPciak
Active Contributor
0 Likes
599

You can do this using field symbols


field-symbols <comp>.

assign component 'AMOUNT' of structure wa_some_structure to <comp>.
if sy-subrc = 0.
   "here <comp> holds value of AMOUNT
endif.

You can replace 'AMOUNT' with any variable which holds the name of component you want to access.

Regards

Marcin

Hello Experts,

How to match a certain value fetched from table to the internal table field.

For instance: transparent table has a column containing values as

AMOUNT

QUANTITY

there is another work area structure associated with different internal table consisting of amount and quantity fields.

Now depending on whether the record from transparent table has fetched AMOUNT or QUANTITY, i have to read either the amount or quantity value from the work area.

Can any one please suggest a technique to do it?

Thanks,

Pankaj

3 REPLIES 3
Read only

MarcinPciak
Active Contributor
0 Likes
600

You can do this using field symbols


field-symbols <comp>.

assign component 'AMOUNT' of structure wa_some_structure to <comp>.
if sy-subrc = 0.
   "here <comp> holds value of AMOUNT
endif.

You can replace 'AMOUNT' with any variable which holds the name of component you want to access.

Regards

Marcin

Read only

0 Likes
599

Thanks Marcin,

Problem resolved with field symbols.

Assigning points

Best Regards,

Pankaj

Read only

Former Member
0 Likes
599

Hi

Try This:

suppose you have zitab table as trans. Table and another table itab1 with work area wa.

First you need to select values from Zitab to an internal table say itab.

sort itab by <field name>

loop at itab.

read table itab1 into wa with key quantity = itab-quantity

amount = itab-amount.

endloop.

This will read table itab1 where quantity and amount from itab table matches.

hope this will work for you.

thanks

Lalit Gupta