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

Assign Component with dynamic structure.

Former Member
41,307

Hi,

I like to get a field from a structure which i read from a customizing table. I think with a snippet it is easy to understand:

FIELD-SYMBOLS: <fs_value> TYPE Any.

DATA: lv_field type text30,

lv_structure type but000,

lv_Structure_name type text30.

select single *

into lv_structure

from but000.

lv_field = 'PARTNER'.

lv_Structure_name = 'LV_STRUCTURE'.

ASSIGN COMPONENT lv_field OF STRUCTURE lv_Structure_name TO <fs_value>.

But this doesn't wok, because it seems, that this statement try to get the fieldname from the variable 'lv_Structure_name'.

If i replace lv_Structure_name with lv_Structure than it works, but this is not what I like.

Any ideas

Stefan

1 ACCEPTED SOLUTION
Read only

jrg_wulf
Active Contributor
10,627

Hi,

with a little addition of a second fs:


FIELD-SYMBOLS: <fs_value> TYPE ANY.
FIELD-SYMBOLS: <fs_struc> TYPE ANY.
DATA: lv_field TYPE text30,
lv_structure TYPE but000,
lv_structure_name TYPE text30.

SELECT SINGLE *
INTO lv_structure
FROM but000.

lv_field = 'PARTNER'.
lv_structure_name = 'LV_STRUCTURE'.
ASSIGN (lv_structure_name) TO <fs_struc>.
ASSIGN COMPONENT lv_field OF STRUCTURE <fs_struc> TO <fs_value>.

it will work.

regards

Jörg

1 REPLY 1
Read only

jrg_wulf
Active Contributor
10,628

Hi,

with a little addition of a second fs:


FIELD-SYMBOLS: <fs_value> TYPE ANY.
FIELD-SYMBOLS: <fs_struc> TYPE ANY.
DATA: lv_field TYPE text30,
lv_structure TYPE but000,
lv_structure_name TYPE text30.

SELECT SINGLE *
INTO lv_structure
FROM but000.

lv_field = 'PARTNER'.
lv_structure_name = 'LV_STRUCTURE'.
ASSIGN (lv_structure_name) TO <fs_struc>.
ASSIGN COMPONENT lv_field OF STRUCTURE <fs_struc> TO <fs_value>.

it will work.

regards

Jörg