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: 

Problem with <field-symbols> usage

former_member125661
Contributor
0 Kudos

Hi guys,

I am trying to read a record of table gi_outtab as follows:

read table gi_outtab into wa_outtab index wa_ir2_data_changed-row_id.

And now i want the value of a field of wa_outtab and this field is contained in a field-symbol <field> .

I thought wa_outtab-<field> would give the value for that field. But it gives syntax error saying component doesn't exist.How do I fix it ? Any help or sample code to fix this error is greatly appreciated.The code is below.

Thanks,

SHK

-


I have fieldname info and row index info in wa_ir2_data_changed.I assign field-name info to a field-symbol.wa_outtab-<field> gives error saying no component like that exists. <field> dynamically changes for ever iteration of the loop below.How do I fix it ?

data : wa_ir2_data_changed like line of ir2_data_changed->mt_good_cells.

field-symbols : <field> type ANY .

loop at ir2_data_changed->mt_good_cells into wa_ir2_data_changed.

assign wa_ir2_data_changed-fieldname to <field> .

read table gi_outtab into wa_outtab index wa_ir2_data_changed-row_id.

call method ir2_data_changed->modify_cell

exporting i_row_id = wa_ir2_data_changed-row_id

i_fieldname = wa_ir2_data_changed-fieldname

i_value = wa_outtab-<field>.

endloop.

wa_ir2_data_changed has 3 components.

a) row_id

b) fieldname

c) value

6 REPLIES 6

suresh_datti
Active Contributor
0 Kudos

Hi Shareen,

Try

i_value = <field>.

Regards,

Suresh Datti

0 Kudos

I dont want to pass fieldname to i_value,

I want to pass the value of a field contained in <field> for a row of gi_outtab where row is given by the index.

0 Kudos

I get a syntax error :

The data object wa_outtab does not have a component called <field>.

Is there any other way of assignment ?The field name whose value i need to find out, changes dynamically with each loop.So I thought field-symbols can be used.

0 Kudos

what is the structure of wa_outtab?

to get the value to i_value, you have to first

ASSIGN wa_outtab-field to <field>.

and then use

i_value = <field>.

Regards,

Suresh Datti

0 Kudos

The following code fixed it.Thanks Suresh for the tip.

loop at ir2_data_changed->mt_good_cells into wa_ir2_data_changed.

read table gi_outtab into wa_outtab index wa_ir2_data_changed-row_id.

ASSIGN COMPONENT wa_ir2_data_changed-fieldname of structure wa_outtab to

<field>.

call method ir2_data_changed->modify_cell

exporting i_row_id = wa_ir2_data_changed-row_id

i_fieldname = wa_ir2_data_changed-fieldname

i_value = <field>.

endloop.

0 Kudos

Hi,

In that case if you know the field name or its position

use the following syntax

loop at itab assigning <fs>

assign component i of structure <fs> to <fk>.

value = <fk>.

endloop.

if you calculate the field position inside loop use i or use the syntax

assign component table field f of structure <fs> to <fk>.

Hope that helps.

regards

austin

ps - reward points if usefull