Skip to Content
4

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

Nov 22, 2017 at 07:54 AM

78

avatar image
Former Member

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

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

2 Answers

Best Answer
Sandra Rossi Nov 22, 2017 at 08:48 PM
2

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)

Show 1 Share
10 |10000 characters needed characters left characters exceeded
Former Member

Ah ok I see. Thanks!

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

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.
Show 1 Share
10 |10000 characters needed characters left 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 :)

0