Entering content frame

Converting into a Sortable Format Locate the document in its SAP Library structure

The CONVERT TEXT statement converts strings into a format that can be sorted alphabetically.

CONVERT TEXT c INTO SORTABLE CODE sc.

This statement writes a string c to a sortable target field sc. The field c must be of type c and the field sc must be of type x with a minimum size of 16 times the size of c.

The field sc can serve as an alphabetic sort key for c. These sorts are applied to internal tables and extract datasets. If you sort unconverted character fields, the system creates an order that corresponds to the platform-specific internal coding of the individual letters. The conversion CONVERT TEXT creates target fields in such a way that, after sorting the target fields, the order of the corresponding character fields is alphabetical.

The method of conversion depends on the text environment of the current ABAP program. The text environment is fixed in the user master record, but can also be set from a program using the following ABAP statement:

SET LOCALE LANGUAGE lg [COUNTRY cy] [MODIFIER m].

This statement sets the text environment in accordance with the language lg. With the COUNTRY addition, you can specify the country in addition to the language, provided there are country-specific differences for languages. With the MODIFIER addition, you can specify another identifier, provided there are differences in the language within one country. For example, in Germany, the order for sorting umlauts is different in a dictionary from the order used in a telephone book.

The fields lg, cy, and m must be of type c and must have the same lengths as the key fields of table TCP0C. Table TCP0C is a table, in which the text environment is maintained platform-dependent. During the statement SET LOCALE, the system sets the text environment according to the entries in TCP0C. With the exception of the platform identity, which is transferred internally, the table key is specified with the SET statement. The platform identifier is passed implicitly. If lg equals space, the system sets the text environment according to the user’s master record. If there is no entry in the table for the key specified, the system reacts with a runtime error.

The text environment influences all operations in ABAP that depend on the character set.

For more information about this topic, see the keyword documentation for CONVERT TEXT and SET LOCALE LANGUAGE.

For an example of alphabetical sorting, see Sorting Internal Tables.

 

 

Leaving content frame