Skip to content

ABAP Keyword Documentation →  ABAP - Short Reference 

SORT itab - Short Reference

Reference

Other versions: 7.31 | 7.40 | 7.54

Syntax


SORT itab [STABLE] 
          { { [ASCENDING|DESCENDING]
              [AS TEXT]
              [BY {comp1 [ASCENDING|DESCENDING] [AS TEXT]}
                  {comp2 [ASCENDING|DESCENDING] [AS TEXT]}
                  ... ] }
          | { [BY (otab)] } }.

Effect

Sorts an internal table itab according to the primary table key or a specified sort key.

Additions

  • STABLE
    Privides stable sorting, where the relative sequence of unrelated rows remaind the same.
  • ASCENDING
    Sorts in ascending order.
  • DESCENDING
    Sorts in descending order.
  • AS TEXT
    Sorts text-type components according to the locale of the current text environment.
  • BY comp1 ... comp2 ...
    Sorts according to the specified components comp1, comp2, ... instead of by primary table key.
  • BY (otab)
    Sorts by the sequence specified in table OTAB of type ABAP_SORTORDER_TAB instead of by primary table key.