I have a generic table of type "any table" and I'm trying to modify some entries in there, in this way:
LOOP AT ct_data INTO <fs_data>.
ASSIGN COMPONENT 'KEY' OF STRUCTURE <fs_data> TO <fs_feld_fu_key>.
IF <fs_feld_fu_key> IS ASSIGNED.
IF <fs_feld_fu_key> = <fs_mci_items>-parent_key.
ASSIGN COMPONENT 'ZZ_CHANGED_FIELD' OF STRUCTURE <fs_data> TO <fs_feld_walzzyk>.
IF <fs_feld_walzzyk> IS ASSIGNED.
<fs_feld_walzzyk> = <fs_mci_items>-zz_changed_field.
MODIFY TABLE ct_data FROM <fs_data>.
ENDIF.
ENDIF.
ENDIF.
ENDLOOP.
Field-Symbols are all having the type "any".
Everything in this code woks just fine, BUT after this line:
MODIFY TABLE ct_data FROM <fs_data>.
I get SY_SUBRC = 4 and the table will not be modified. Does anybody have some ideas or tips? What am I doing wrong in this case?
Full code:
DATA: rt_data TYPE REF TO data,
ls_key TYPE /bobf/s_frw_key,
lt_key TYPE /bobf/t_frw_key.
FIELD-SYMBOLS: <fs_data> TYPE any,
<fs_feld_fu_key> TYPE any,
<fs_feld_walzzyk> TYPE any.
CREATE DATA rt_data LIKE LINE OF ct_data.
ASSIGN rt_data->* TO <fs_data>.
IF <fs_data> IS ASSIGNED.
LOOP AT ct_data INTO <fs_data>.
ASSIGN COMPONENT 'fu_key' OF STRUCTURE <fs_data> TO <fs_feld_fu_key>.
IF <fs_feld_fu_key> IS ASSIGNED.
ls_key-key = <fs_feld_fu_key>.
APPEND ls_key TO lt_key.
ENDIF.
ENDLOOP.
ENDIF.
/scmtms/cl_tor_helper_read=>get_tor_data(
EXPORTING
it_root_key = lt_key
IMPORTING
et_mci_items = DATA(lt_mci_items)
).
LOOP AT lt_mci_items ASSIGNING FIELD-SYMBOL(<fs_mci_items>).
LOOP AT ct_data INTO <fs_data>.
ASSIGN COMPONENT 'FU_KEY' OF STRUCTURE <fs_data> TO <fs_feld_fu_key>.
IF <fs_feld_fu_key> IS ASSIGNED.
IF <fs_feld_fu_key> = <fs_mci_items>-parent_key.
ASSIGN COMPONENT 'ZZ_CHANGED_FIELD' OF STRUCTURE <fs_data> TO <fs_feld_walzzyk>.
IF <fs_feld_walzzyk> IS ASSIGNED.
<fs_feld_walzzyk> = <fs_mci_items>-zz_walzzyklus.
MODIFY TABLE ct_data FROM <fs_data>.
ENDIF.
ENDIF.
ENDIF.
ENDLOOP.
ENDLOOP.
ASSIGN ... TO <fs>
, testingIF <fs> IS ASSIGNED
may be an error if at the same time the assignment was erroneous AND <fs> was previously assigned. Just check your full code (maybe you have more lines?). If that's the case, then replace theIF <fs> IS ASSIGNED
withIF sy-subrc = 0.
– Sandra Rossi