Ansicht
Dokumentation

ABAPSORT_EXTRACT - SORT EXTRACT

ABAPSORT_EXTRACT - SORT EXTRACT

General Data in Customer Master   Addresses (Business Address Services)  
This documentation is copyright by SAP AG.
SAP E-Book

SORT, Extract

Short Reference



SORT $[ASCENDING$|DESCENDING$]
     $[AS TEXT$]
     $[STABLE$]
     $[sort_key$].

Additions

1. ... ASCENDING$|DESCENDING

2. ... AS TEXT

3. ... STABLE

Effect

This statement sorts the extract dataset of the program. A prerequisite for executing the statement is that the field group header is defined using the statement FIELD-GROUPS, and is therefore a component of all field groups. If no explicit sort key sort_key is specified, the extract dataset is sorted by the components of the field group header. Numeric and byte-like components are sorted according to their value and character-like components are sorted by default according to their binary representation (code page). Here, components containing hexadecimal 0 are placed in front of other entries. Text sorting for character-like components can be done using the addition AS TEXT.

The priority of sorting is based on the order in which the components are inserted into the field group header using INSERT.

Sorting is unstable by default, which means that the relative order of rows that do not differ in their sort keys is not preserved when they are sorted, and can change when a sort is performed multiple times. The addition STABLE can be used for stable sorting.

The statement SORT also completes the structure of the extract dataset. Executing the statement EXTRACT after executing the statement SORT raises an uncatchable exception.

Notes

  • The only difference between the syntax of the statement SORT for the extract dataset and the statement SORT for internal tables is that no internal table is specified. Regardless of this, the two should not be confused with one another.
  • If components with the content hexadecimal 0 are placed in front of other entries, this can lead to unexpected behavior when sorting numeric data types.
  • In global classes, no field groups can be defined or processed. In methods of local classes of programs other than class pools, the statement SORT is possible for globally defined field groups.

Addition 1

... ASCENDING$|DESCENDING

Effect

The addition ASCENDING or DESCENDING can be used to specify the sort direction explicitly as ascending or descending. If neither addition is specified, the data is sorted in ascending order by default. The sort direction can be overwritten for individual components in the explicit sort key sort_key.

Addition 2

... AS TEXT

Effect

The addition AS TEXT specifies that text-like components are sorted according to the locale of the current text environment. If AS TEXT is not specified, text-like components are sorted according to the encoding in the code page of the current text environment. For more information, see SORT for internal tables.



Addition 3

... STABLE

Effect

STABLE can be used to perform stable sorting. The relative order of rows, which is the same in the sort key, remains unchanged during sorting. Without the addition STABLE, the order is not stable and repeated sorting of the extract dataset with the same sort key can change the order in each sort.

Extracts, Processing

Exceptions

Non-Catchable Exceptions

  • Cause: A sort field with the explicit addition AS TEXT is not text-like.
    Runtime Error: SORT_AS_TEXT_EX_BAD_TYPE
  • Cause: More than 50 sort criteria.
    Runtime Error: SORT_EXTRACT_TOO_MANY_FIELDS
  • Cause: The field group HEADER does not contain a sort criterion.
    Runtime Error: SORT_FIELD_NOT_IN_HEADER
  • Cause: The field group HEADER is not defined.
    Runtime Error: SORT_NO_HEADER
  • Cause: It is not possible to use SORT in a loop across an extract dataset.
    Runtime Error: SORT_WITHIN_LOOP
  • Cause: Insufficient memory space.
    Runtime Error: SORT_EXTRACT_INDEX_NO_ROLL








TXBHW - Original Tax Base Amount in Local Currency   BAL_S_LOG - Application Log: Log header data  
This documentation is copyright by SAP AG.

Length: 7204 Date: 20240508 Time: 045604     sap01-206 ( 103 ms )