‎2008 Jun 23 8:34 AM
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
‎2008 Jun 23 8:43 AM
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