Sorting Internal Tables in ABAP - Sorting alphabetically
Details
- Details
- Category: ABAP
- Created on Thursday, 15 November 2012 08:37
- Last Updated on Thursday, 15 November 2012 08:43
- Published on Thursday, 15 November 2012 08:37
- Written by Administrator
- Hits: 26015
Sorting Alphabetically
As well as the ASCENDING or DESCENDING addition, you can also specify that the entire sort or each sort field should be alphabetical.
SORT <itab> ... AS TEXT ... .
This addition affects the sort method for strings. Without the addition, strings are sorted according to the sequence specified by the hardware platform. With the option AS TEXT, the system sorts character fields alphabetically according to the current text environment. By default, the text environment is set in the user master record. However, you can also set it specifically using the statement
SET LOCALE LANGUAGE
The AS TEXT addition saves you having to convert strings into a sortable format. Such a conversion is only necessary if you want to
Sort an internal table alphabetically and then use a binary search
resort an internal table with character fields as its key several times, since only one conversion is then required
Construct an alphabetical index for database tables in your program
If the AS TEXT addition is applied to the entire sort, it only affects sort fields with type C. If you apply the AS TEXT addition to a single sort field, it must have type C.