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_INTORelated Rules
- Do Not Mutate the Internal Table Currently Being Looped (Iterator Invalidation) —
#EC NO_MOD_LOOP_TAB - Modernize READ TABLE (Table Expressions & line_exists) —
#EC PREF_TAB_EXPR - Avoid String Concatenation Inside Loops (Quadratic Memory Allocation) —
#EC NO_CONCAT_LOOP
Technical Details
- Native ATC Class:
ZCL_SKYLINT_NO_LOOP_INTO - Implementation File: zcl_skylint_no_loop_into.clas.abap