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

Dynamic access to work area fields

Former Member
0 Likes
1,515

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???

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
694

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.

2 REPLIES 2
Read only

Former Member
0 Likes
695

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.

Read only

Former Member
0 Likes
694

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.