SAP SORT KEY ABAP Statements

Get Example source ABAP code based on a different SAP table
  



SORT - sort_key

Short Reference
• BY SORT - extract (obsolete)

ABAP Syntax(Obsolete)... BY field1 [ASCENDING|DESCENDING] [AS TEXT]
field2 [ASCENDING|DESCENDING] [AS TEXT]
... .

ABAP Addition
1 ... ASCENDING|DESCENDING
2 ... AS TEXT

What does it do? When a sort key is specified with the BY addition, sorting is not done by field group header, but by the field1 field2 ... fields specified after it. For field1 field2 ..., only components of field group header or field groups that contain solely fields of field group header can be specified. The sort order depends on the sequence in which the components field1 field2 ... are specified. The number of fields to be used for sorting is limited to 50.

For field1 field2 ..., field symbols can also be specified. If a component of the field group header is assigned to a field symbol when the statement is executed, sorting takes place according to the respective component. If no data object is assigned to a field symbol, the specification is ignored. If a different data object is assigned to a field symbol, an untreatable exception is triggered.



Latest notes:For field1 field2 ..., no
ABAP Code Snippet be specified if they are empty.
• ASCENDING SORT BY - extract (obsolete)
• DESCENDING SORT BY - extract (obsolete)

ABAP Addition

If, after a component field1 field2 ..., neither of the ASCENDING or DESCENDING additions is specified, the predefined sort direction is applied. If one of the additions ASCENDING or DESCENDING is specified, it overwrites the default for this component.
• AS TEXT SORT BY - extract (obsolete)

ABAP Addition

Without the addition AS TEXT after a text-like component field1 field2 ..., the default is applied. If the addition AS TEXT is specified after a text-like component, it overwrites the default for this component. In the case of non-text-like components, AS TEXT cannot be specified. If AS TEXT is specified after a field group, the addition is only applied to the text-like components of this group.

Return to menu