‎2008 Jan 14 11:59 AM
Hi
I've got a DataBase table with 20 fields with different names.
field1
field2
field3.
....
field20
I'm using a work area to read values and i wanna read an specific field of this work area.
The problem is the following:
I don't know the name of the field i need to access, instead, i have it in a field symbol.
Is there any way i can get the value of this field???
‎2008 Jan 14 12:45 PM
Hi,
Try the following example
DATA: i_TAB LIKE PA0001 OCCURS 0 WITH HEADER LINE,
l_field(50) TYPE C,
l_fieldname(50) TYPE C VALUE 'UNAME'.
FIELD-SYMBOLS: <fieldxx> TYPE ANY,
<valxx> TYPE ANY.
ASSIGN l_fieldname TO <fieldxx>.
SELECT * FROM PA0001 INTO TABLE I_TAB.
LOOP AT I_TAB.
CONCATENATE 'I_TAB-' <fieldxx> INTO l_field.
ASSIGN (l_field) TO <valxx>.
WRITE <valxx>.
ENDLOOP.
‎2008 Jan 14 12:45 PM
Hi,
Try the following example
DATA: i_TAB LIKE PA0001 OCCURS 0 WITH HEADER LINE,
l_field(50) TYPE C,
l_fieldname(50) TYPE C VALUE 'UNAME'.
FIELD-SYMBOLS: <fieldxx> TYPE ANY,
<valxx> TYPE ANY.
ASSIGN l_fieldname TO <fieldxx>.
SELECT * FROM PA0001 INTO TABLE I_TAB.
LOOP AT I_TAB.
CONCATENATE 'I_TAB-' <fieldxx> INTO l_field.
ASSIGN (l_field) TO <valxx>.
WRITE <valxx>.
ENDLOOP.
‎2008 Jan 14 12:55 PM
Try this,
I am considering 'MARA' as my work area name, <fieldname> as the fieldstring with the fieldname.
FIELD_SYMBOLS : <value> type any.
DATA: fn type string.
concatenate 'MARA-' <fieldname> into fn.
assign (fn) to <value>.
Now the field string <value> will have the required value from the work area's appropriate field.