Skip to content

Do Not Mutate the Internal Table Currently Being Looped ​

WarningPerformance & Database#EC LOOP_MODIFYRemote Enabled

Overview ​

Avoid mutating or sorting tables inside loops.

ATC Finding Messages:

  • Do not add, delete, sort, collect, or clear rows from the table currently being looped
  • Avoid sorting internal tables inside loops to prevent severe performance degradation

Rationale ​

Appending, inserting, modifying, or deleting rows of the table being looped can invalidate the loop cursor. The result may be skipped rows, duplicate processing, or an endless loop. Iterate over a snapshot or collect changes in a separate table and apply them after the loop.

Non-Compliant ​

abap
LOOP AT lt_orders INTO ls_order.
  INSERT ls_order INTO lt_orders.
ENDLOOP.

Compliant ​

abap
LOOP AT lt_orders INTO ls_order.
  INSERT ls_order INTO lt_processed_orders.
ENDLOOP.

Configuration & Thresholds ​

This check can be fine-tuned directly in the ATC Check Variant Editor (CHKV) in Eclipse ADT:

Parameter NameData TypeDefault Value
CHECK_APPENDBooleantrue
CHECK_INSERTBooleantrue
CHECK_MODIFYBooleantrue
CHECK_DELETEBooleantrue
CHECK_CLEARBooleantrue
CHECK_SORTBooleantrue
CHECK_SORT_ANYBooleantrue
CHECK_COLLECTBooleantrue

Suppression ​

To suppress findings for this rule, append the pseudo-comment to the statement:

abap
" Standard pseudo-comment:
... "#EC LOOP_MODIFY

" SAP CI_ prefix format:
... "#EC CI_LOOP_MODIFY

Technical Details ​

Released under the MIT License.