Skip to content

Avoid Duplicate Subexpressions in the Same Statement ​

NoteAnti-Patterns & Bad Practices#EC NO_DUP_SUBEXPRRemote Enabled

Overview ​

Avoid duplicate subexpressions in the same statement.

ATC Finding Message: Avoid repeating duplicate subexpressions; evaluate once into a variable

Rationale ​

Evaluating the exact same table expression (e.g. lt_orders[ 1 ]-net + lt_orders[ 1 ]-vat) or method call multiple times in the same statement triggers redundant internal table index lookups, hash computations, or method executions. In performance-critical logic, this causes unnecessary overhead.

Best Practice: Evaluate the common subexpression once into a local helper variable or field-symbol and reuse it.

Non-Compliant ​

abap
lv_total = lt_orders[ 1 ]-net + lt_orders[ 1 ]-vat.

Compliant ​

abap
DATA(ls_order) = lt_orders[ 1 ].
lv_total = ls_order-net + ls_order-vat.

Suppression ​

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

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

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

Technical Details ​

Released under the MIT License.