Skip to content

Prefer ASSIGNING over LOOP INTO Copy Targets ​

WarningPerformance & Database#EC NO_LOOP_INTORemote Enabled

Overview ​

Prefer ASSIGNING over LOOP INTO copy targets.

ATC Finding Message: Loop copies each row; use ASSIGNING with a field symbol

Rationale ​

LOOP AT ... INTO ls_row copies every table row into a work area before the body runs. For read-only loops this allocation and copy is pure overhead; ASSIGNING FIELD-SYMBOL(<ls_row>) iterates by reference and keeps the code allocation-free. The rule flags LOOP statements that use INTO without ASSIGNING or REFERENCE INTO, and deliberately leaves READ TABLE ... INTO to pref-read-table to avoid duplicate findings.

Non-Compliant ​

abap
LOOP AT lt_items INTO ls_item.
  lv_total = lv_total + ls_item-amount.
ENDLOOP.

Compliant ​

abap
LOOP AT lt_items ASSIGNING FIELD-SYMBOL(<ls_item>).
  lv_total = lv_total + <ls_item>-amount.
ENDLOOP.

Suppression ​

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

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

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

Technical Details ​

Released under the MIT License.