10-09-2007 9:05 AM
Hi all,
T_TEMP contains the fields
matnr, mng001, mng002 . . .mng0010.
Now i have to move a value to the MNG fields dynamically. Is it possible by field symbols.
do 10 times.
CONCATENATE 'T_TEMP-MNG0' l_val INTO l_tempstr.
l_tempstr = '400'.
enddo.
now the l_tempstr value only changes. But i want T_TEMP-MNG001 to be changed. Is it possible.
10-09-2007 12:28 PM
Hi,
dinesh's apporach is not bad, but
1. the structure' name cannot be part of the component
2. you need to make sure the component-name always is in upper case.
Try adapting the following code:
data: begin of wa_test,
field01 type string,
field02 type string,
field03 type string,
end of wa_test.
data: l_fieldname type string,
l_counter type string.
field-symbols: <testc> type string.
do 3 times.
l_counter = sy-index.
concatenate 'field0' l_counter into l_fieldname.
translate l_fieldname to upper case.
assign component l_fieldname of structure wa_test to <testc>.
if <testc> is assigned.
<testc> = 'any value'.
endif.
enddo.
write / wa_test-field01.
best regards
10-09-2007 9:20 AM
Hi TRY using this way .
declare a workarea of type t_temp .
Field Symbol : <f1> type any .
do 10 times .
concatenate 'T_TEMP-MNG0' sy-index into v_}var
assign component v_var of structure wa_temp to <f1>.
<f> = '400'.
enddo.
Please reward if useful.
10-09-2007 9:48 AM
Hi dinesh,
If value is assigned like this <f> = '400', only the field symbol value is getting changed and not the field. If possible could u mail me any example source code.
10-09-2007 12:28 PM
Hi,
dinesh's apporach is not bad, but
1. the structure' name cannot be part of the component
2. you need to make sure the component-name always is in upper case.
Try adapting the following code:
data: begin of wa_test,
field01 type string,
field02 type string,
field03 type string,
end of wa_test.
data: l_fieldname type string,
l_counter type string.
field-symbols: <testc> type string.
do 3 times.
l_counter = sy-index.
concatenate 'field0' l_counter into l_fieldname.
translate l_fieldname to upper case.
assign component l_fieldname of structure wa_test to <testc>.
if <testc> is assigned.
<testc> = 'any value'.
endif.
enddo.
write / wa_test-field01.
best regards
10-09-2007 1:06 PM
Hi Das,
Thank u very much for your clear explanation....Ur idea works fine.
Regards,
Vijay.
10-10-2007 12:33 PM
Hi Vijay ,
My reply was also same as Das Omen except without code.