08-24-2005 3:21 PM
The following piece of code is used to assign the value of a field in an internal table to a field in a workarea.
lwa_subscr - workarea
li_subscrbe - Internal table
1. loop at li_subscrbe.
2. lwa_subscr-mailerid = li_subscrbe-mailerid.
3. lwa_subscr-cust_no = li_subscrbe-cust_no.
*this assigns the field name dynamically to a string variable 'event_field'
4. concatenate 'lwa_subscr-' li_subscrbe-eventid into event_field.
5. assign table field event_field to <fs_event>.
6. move li_subscrbe-subscr_value to <fs_event>.
7. endloop.
i want to assign the value of a field 'subscr_value' in internal table 'li_subscrbe', into a field of workarea.
The 'move' statement assigns the value to field symbol and not to the field stored in the field symbol.
example:
Before line 5, the value of field symbol <fs_event> has value 'lwa_subscr-volume' where 'volume' is one of the columns of the work area.
But in line 6, i want the integer value in 'li_subscrbe-subscr_value' to be assigned to 'lwa_subscr-volume', but the interger value gets assisgned to the field symbol itself.
how else can i implement this.
08-24-2005 3:54 PM
In your ASSIGN statement, make sure that you have parenthesis around the field.
report zrich_0002.
data: begin of itab occurs 0,
field1 type i,
end of itab.
data: wa like line of itab.
data: wa_field(20) type c.
field-symbols: <fs1>,
<fs2>.
itab-field1 = '1234'.
append itab.
read table itab index 1.
concatenate 'WA' 'FIELD1' into WA_field separated by '-'.
<b>assign (wa_field) to <fs1>.</b>
move itab-field1 to <fs1>.
write:/ <fs1>.
Regards,
Rich Heilman
08-24-2005 3:54 PM
In your ASSIGN statement, make sure that you have parenthesis around the field.
report zrich_0002.
data: begin of itab occurs 0,
field1 type i,
end of itab.
data: wa like line of itab.
data: wa_field(20) type c.
field-symbols: <fs1>,
<fs2>.
itab-field1 = '1234'.
append itab.
read table itab index 1.
concatenate 'WA' 'FIELD1' into WA_field separated by '-'.
<b>assign (wa_field) to <fs1>.</b>
move itab-field1 to <fs1>.
write:/ <fs1>.
Regards,
Rich Heilman
08-25-2005 4:40 AM
08-24-2005 4:05 PM
hi, you can reference the code as following:
types:begin of typ_test,
field1 type char10,
field2 type char10,
field3 type char10,
end of typ_test.
data: it_test type standard table of typ_test,
lc_test like line of it_test,
lc_test2 like line of it_test,
lc_fldname type char10,
lc_fldname2 type char10,
dref TYPE REF TO DATA.
field-symbols: <fs>, <fs2>.
lc_test-field1 = 1.
lc_test-field2 = 2.
lc_test-field3 = 3.
append lc_test to it_test.
loop at it_test into lc_test.
get reference of lc_test2 into dref.
ASSIGN dref->* TO <fs>.
assign component 'FIELD1' of structure <fs> to <fs2>.
<fs2> = lc_test-field1.
* you can find lc_test2-field1 has a value already
endloop.
Hope it will be valuable.
thanks