SAP OO OBS LOOP 1

Get Example source ABAP code based on a different SAP table
  


ABAP Code Snippet
ARTICLE

Cannot Change an Internal Table in a Loop
You cannot change a complete internal table in a loop operating on this table in ABAP Objects. Changes to the table as a whole may be caused by, for example, the REFRESH , CLEAR, FREE, MOVE, SORT, or SELECT INTO TABLE statements. This applies to internal tables from procedures and internal tables imported from a data cluster.

In ABAP Objects, the following statements cause an error message:

LOOP AT itab INTO wa.
CLEAR itab.
ENDLOOP.
Correct syntax:

LOOP AT itab INTO wa.
...
ENDLOOP.
CLEAR itab.
Cause:

When the table is accessed again, system behavior will be unpredictable and may lead to runtime errors.