Specify an Explicit SORT Key with BY
WarningPerformance & Database#EC PREF_SORT_KEYRemote Enabled
Overview
Sort With an Explicit Sort Key.
ATC Finding Message:
SORT statement has no explicit BY key - implicit standard key is used
Rationale
SORT without BY sorts an internal table using its implicit standard key, which depends on the table definition (character-type components for standard tables). This makes the sort result fragile: key changes ripple into sort behavior, character field shortening alters comparisons, and unsorted parallel sorts become unpredictable. Specify the sort key explicitly with SORT ... BY so the statement is robust and self-documenting.
Non-Compliant
abap
SORT lt_data.Compliant
abap
SORT lt_data BY field1 field2.Suppression
To suppress findings for this rule, append the pseudo-comment to the statement:
abap
" Standard pseudo-comment:
... "#EC PREF_SORT_KEY
" SAP CI_ prefix format:
... "#EC CI_PREF_SORT_KEYRelated Rules
- Explicitly Specify SORT Order —
#EC PREF_SORT_ORDER - Prefer TYPE STANDARD TABLE OF over TYPE TABLE OF —
#EC PREF_STD_TABLE
Technical Details
- Native ATC Class:
ZCL_SKYLINT_PREF_SORT_KEY - Implementation File: zcl_skylint_pref_sort_key.clas.abap