Skip to Content
avatar image
Former Member

'Is not a field name' error when appending to a nested table

Hey,

I want to append a structure into a table that is part of a structure. This structure is saved in another table I access via '[ key = key_value ]'. I know that this is not the most performant approach but does anyone know why this is not working?

The error is: "MT_GROUPED_CHANGES[" is not a field name

if line_exists( mt_grouped_changes[ receiver_name = receiver_name ] ).
  append ls_change to mt_grouped_changes[ receiver_name = receiver_name ]-changes.
endif.

Best regards,

Max

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Best Answer
    Nov 22, 2017 at 08:48 PM

    In APPEND ... TO itab, itab is not meant to be a "functional operand position"; as nothing is specified in the ABAP documentation, it must just be an internal table:

    If you look at READ TABLE itab, this is different, itab may be a "functional operand position":

    (and for the question "why SAP did it like that", I don't know)

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Nov 22, 2017 at 09:42 AM

    Can you try something like this?

    I do not have system now so it may have some errors.

    ASSIGN mt_grouped_changes[ receiver_name = receiver_name ] TO FIELD-SYMBOL(<lfs_mt>).
    IF sy-subrc = 0.
      APPEND ls_change TO <lfs_mt>-changes.
    ENDIF.
    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      Yes this works and I also found another suitable solution but I would like to know why my original solution is not working.

      But thanks for the answer :)