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

Create DATA

Former Member
0 Likes
269

Hi Experts,

I have a similar code as this:

DATA: dref TYPE REF TO data.

FIELD-SYMBOLS: <l_fs_po> TYPE ANY.

CASE i_datasource.

WHEN 'case1'.

CREATE DATA dref TYPE struct_1.

ASSIGN dref->* TO <l_fs_po>.

WHEN 'case2'.

CREATE DATA dref TYPE struct_1.

ASSIGN dref->* TO <l_fs_po>.

' more cases here

ENDCASE

<l_fs_po>-fieldname1 = 'valuehere'.

I got a compilation error message that <l_fs_po> has no structure and therefore does not have

a component fieldname1. Doesn't it consider that I declared <l_fs_po> as of type ANY?

did I miss anything here? or is there another alternative so I could change my code and achieve

the same objective.

My objective is to assign the structure at runtime to a variable.

Any help will be very much appreciated.

Thanks,

Rose

1 REPLY 1
Read only

JozsefSzikszai
Active Contributor
0 Likes
250

hi Rose,

"Doesn't it consider that I declared <l_fs_po> as of type ANY?"

yes it does, this is why you get the error message. The exact structure of <l_fs_po> will only be known at runtime and NOT at compiler time. So this <l_fs_po>-fieldname1 = 'valuehere'. have no chance to wrok, you have to do:

ASSIGN COMPONENT 'field' OF STRUCTURE <l_fs_po> TO <field_symbol>.

hope this helps

ec