abap sort by
时间: 2023-07-05 18:05:30 浏览: 52
ABAP provides the SORT statement to sort internal tables. The basic syntax for sorting an internal table in ABAP is:
```
SORT <internal table>
[BY <key field> {ASC | DESC}]
[USING <comparison function>].
```
Where:
- `<internal table>` is the name of the internal table to be sorted.
- `<key field>` is the name of the field used as the sort key.
- `ASC` or `DESC` is the order of sorting (ascending or descending).
- `<comparison function>` is an optional parameter used to specify a custom comparison function for sorting.
Example usage:
```
DATA: itab TYPE STANDARD TABLE OF mara WITH KEY matnr.
* Sort the internal table by material number field in ascending order
SORT itab BY matnr ASCENDING.
* Sort the internal table by material description field in descending order
SORT itab BY maktx DESCENDING.
* Sort the internal table using a custom comparison function
SORT itab USING compare_function.
```