Sort Internal Tables Before DELETE ADJACENT DUPLICATES
WarningAnti-Patterns & Bad Practices#EC NO_DEDUP_NO_SORTRemote Enabled
Overview
Sort internal tables before DELETE ADJACENT DUPLICATES.
ATC Finding Message:
Sort internal table before DELETE ADJACENT DUPLICATES to prevent unexpected results
Rationale
DELETE ADJACENT DUPLICATES only removes duplicate rows that are physically consecutive. If the table is not sorted beforehand, non-adjacent identical rows are retained, leading to subtle logic errors and incomplete deduplication.
Standard: Always issue an explicit SORT <itab> statement immediately before DELETE ADJACENT DUPLICATES.
Non-Compliant
abap
" Flawed deduplication: Unsorted adjacent check misses duplicates
DELETE ADJACENT DUPLICATES FROM lt_data.Compliant
abap
" Correct: Explicit sort guarantees consecutive duplicates
SORT lt_data.
DELETE ADJACENT DUPLICATES FROM lt_data.Suppression
To suppress findings for this rule, append the pseudo-comment to the statement:
abap
" Standard pseudo-comment:
... "#EC NO_DEDUP_NO_SORT
" SAP CI_ prefix format:
... "#EC CI_NO_DEDUP_NO_SORTRelated Rules
- Specify an Explicit SORT Key with BY —
#EC PREF_SORT_KEY - Explicitly Specify SORT Order —
#EC PREF_SORT_ORDER
Technical Details
- Native ATC Class:
ZCL_SKYLINT_NO_DEDUP_NO_SORT - Implementation File: zcl_skylint_no_dedup_no_sort.clas.abap