Explicitly Specify SORT Order
WarningClean ABAP & Modern Syntax#EC PREF_SORT_ORDERRemote Enabled
Overview
Explicitly specify ASCENDING or DESCENDING sort order.
ATC Finding Message:
Specify ASCENDING or DESCENDING sort order explicitly
Rationale
When sorting internal tables by components using the BY addition, no implicit sorting order should be assumed. Developers should explicitly specify ASCENDING or DESCENDING for each field, or specify the default order before BY, making the intended order clear and resilient to future modifications.
Non-Compliant
abap
SORT lt_table BY field1 field2.Compliant
abap
SORT lt_table BY field1 ASCENDING field2 DESCENDING.
SORT lt_table ASCENDING BY field1 field2.Configuration & Thresholds
This check can be fine-tuned directly in the ATC Check Variant Editor (CHKV) in Eclipse ADT:
| Parameter Name | Data Type | Default Value | Description & Guidance |
|---|---|---|---|
CHECK_BY_ONLY | Boolean | true | Only enforce explicit order when the BY addition is used (defaults to true) |
Suppression
To suppress findings for this rule, append the pseudo-comment to the statement:
abap
" Standard pseudo-comment:
... "#EC PREF_SORT_ORDER
" SAP CI_ prefix format:
... "#EC CI_PREF_SORT_ORDERRelated Rules
- Do Not Mutate the Internal Table Currently Being Looped (Iterator Invalidation) —
#EC NO_MOD_LOOP_TAB - Avoid Obsolete Control Flow and Procedural Forms —
#EC NO_OBS_CONTROL
Technical Details
- Native ATC Class:
ZCL_SKYLINT_PREF_SORT_ORDER - Implementation File: zcl_skylint_pref_sort_order.clas.abap