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 value to dynamicly created table

Former Member
0 Likes
394

field-symbols: <dyn_table> type standard table,

<dyn_wa>,

<dyn_field>.

loop at <dyn_table> into <dyn_wa>.

do.

assign component sy-index

of structure <dyn_wa> to <dyn_field>.

if sy-subrc 0.

exit.

endif.

if sy-index = 1.

write:/ <dyn_field>.

else.

write: <dyn_field>.

endif.

enddo.

endloop.

In <Dyn_table> i have created feilds F1, F2,F3 dynamicly and so in <dyn_wa> . with this code i can read the feilds F1,F2,F3 from <Dyn_WA> but what if i want assign a value to it like

<Dyn_table> -F1 = 123 " This code is not working as feilds are added dynamicly to it ....

Please advice how we can do <Dyn_table> -F1 = 123 some thing like this

field-symbols: <dyn_table> type standard table,

<dyn_wa>,

<dyn_field>.

loop at <dyn_table> into <dyn_wa>.

do.

assign component sy-index

of structure <dyn_wa> to <dyn_field>.

if sy-subrc 0.

exit.

endif.

if sy-index = 1.

write:/ <dyn_field>.

else.

write: <dyn_field>.

endif.

enddo.

endloop.

In <Dyn_table> i have created feilds F1, F2,F3 dynamicly and so in <dyn_wa> . with this code i can read the feilds F1,F2,F3 from <Dyn_WA> but what if i want assign a value to it like

<Dyn_table> -F1 = 123 " This code is not working as feilds are added dynamicly to it ....

Please advice how we can do <Dyn_table> -F1 = 123 some thing like this

2 REPLIES 2
Read only

Former Member
0 Likes
369

direct assignment wont work with fieldsymbol

<Dyn_table> -F1 = 123 "wrong

try using either of the two

1) move 123 to <Dyn_table> -F1 .

or

2) assing '123' to <Dyn_table> -F1.

Read only

Former Member
0 Likes
369

Hi,


FIELD-SYMBOLS:<l_fs_dyn> TYPE ANY,
                           <l_fs_bom> TYPE ANY.

LOOP AT p_fcat INTO ls_fcat1 WHERE col_pos <= 10.
* Do not upload characteristics
      ASSIGN COMPONENT ls_fcat1-fieldname
          OF STRUCTURE <dyn_wa> TO <l_fs_dyn>.

      ASSIGN COMPONENT ls_fcat1-fieldname
          OF STRUCTURE it_final_bom1 TO <l_fs_bom>.
      <l_fs_dyn> = <l_fs_bom>.
    ENDLOOP."  

Thanks & Regards,

Krishna..