Application Development 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: 

MOVE_TO_LIT_NOTALLOWED_NODATA error when passing values to a local field symbol.

walkerist
Participant
0 Kudos

Here's the error:

Assignment error: Overwriting of a protected field.

Here is my code:

lt_vbup_key TYPE vbup_key_tab.
APPEND INITIAL LINE TO lt_vbup_key ASSIGNING FIELD-SYMBOL(<lfs_vbuk>).
<lfs_vbuk>-vbeln = tvbdpl-vbeln. <<<<<<<<<<<<<<<<<<< Experiencing dump here
7 REPLIES 7

jens_michaelsen
Participant

We cannot see, how do you define vbup_key_tab. Maybe it's a sorted table with unique key. In this case you can't overwrite the key field, because it's protected.

DominikTylczyn
Active Contributor

Hello walkerist

Your lt_vbup_key is defined with VBUP_KEY_TAB table type, which is a sorted table with VBELN in the primary key:

You must not change a primary key of an existing record of a sorted table.

APPEND INITIAL LINE TO lt_vbup_key ASSIGNING FIELD-SYMBOL(<lfs_vbuk>).

creates an initial record in the internal table. Then

<lfs_vbuk>-vbeln = tvbdpl-vbeln.

tries to overwrite the primary key of that initial record. That is not allowed.

Best regards

Dominik Tylczynski

walkerist You must never use APPEND with an internal table of type SORTED or HASHED. Instead you must use INSERT ... INTO TABLE ...

(INSERT ... INTO TABLE ... can also be used for one of type STANDARD, it does the same as APPEND).

matt
Active Contributor

sandra.rossi - I think you should never use APPEND for any internal table. Always use INSERT.

walkerist

INSERT INITIAL LINE INTO TABLE lt_vbup_key ASSIGNING FIELD-SYMBOL(<lfs_vbuk>).

<lfs_vbuk>-vbeln = tvbdpl-vbeln.

will also not work, as it modifies the key of the internal table which is not allowed.

I suggest instead

INSERT VALUE #I( vbeln = tvbdpl-vbeln ) INTO TABLE lt_vbup_key.

Finally

<lfs_vbuk>. FS as a prefix? Isn't the fact it's surround by < > sufficient indication that it's a field-symbol?

0 Kudos

So the best solution here is to assign tvbdpl-vbeln into a local variable instead?

0 Kudos

walkerist You need to build a new record as a structure, update all the data in the structure and then insert the record to the internal table.

walkerist Do whatever you want, what is important is what Dominik said: "You must not change a primary key of an existing record of a sorted table." (and generally speaking, it would be "sorted or hashed table")