SAP SORT KEY ABAP Statements



Get Example source ABAP code based on a different SAP table
  


• BY SORT - extract (obsolete)

SORT, sort_key
Short Reference

ABAP_SYNTAX_OBS
... 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 using the addition BY, 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 only fields of field group header can be specified. The sort order depends on the order 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 corresponding 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 uncatchable exception is raised.



Latest notes: