Skip to content

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 NameData TypeDefault ValueDescription & Guidance
CHECK_BY_ONLYBooleantrueOnly 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_ORDER

Technical Details ​

Released under the MIT License.