SAP USE OPERAND POSITION - Guide
Get Example source ABAP code based on a different SAP table
Using Elements in Operand Positions
ABAP_BACKGROUND
Statements that modify the content of system fields generally evaluate the operands first and then set the system fields. In some complex statements, however, a system field could be set first, before all operand positions are evaluated.
ABAP_RULE
For reasons of robustness, do not use system fields as operands of statements that themselves set these system fields.
ABAP_DETAILS
A program does not always define whether a particular system field is set in a statement before or after an operand is evaluated. This means that, to reduce risks and to make the program easier to read, the content of a system field should always be copied to a helper variable and only this copy should be used within the statement in question.
Latest notes:
Also take note of how functional methods are used in operand positions. These methods also modify important system fields. Also be careful here when using system fields in operand positions of the same statement.
ABAP_HINT_END
ABAP_EXAMPLE_BAD
The following source code shows how the system field
...
READ TABLE itab2 ... • sy-tabix.
...
ENDLOOP.>
ABAP_EXAMPLE_END
ABAP_EXAMPLE_GOOD
The following source code makes the example above more robust by assigning the value of the system field
index = sy-tabix.
...
.... itab2[ index ] ...
...
ENDLOOP.>
ABAP_EXAMPLE_END