Get Example source ABAP code based on a different SAP table
ID CONVERT-TEXT • CONVERT TEXT ABAP Statement • INTO SORTABLE CODE CONVERT TEXT
CONVERT TEXT> Short Reference >
ABAP_SYNTAX CONVERT TEXT text INTO SORTABLE CODE hex.>
What does it do? The content of the operand text> is converted to a sortable byte string and the result is assigned to the target field hex>. The data object text> itself remains unchanged. The operand text> must be of the type c> or string>. text> is a character-like expression position>. The following can be specified for hex>:
An existing byte-like variable.
An inline declaration DATA(var)>> or FINAL(var)>>, where a variable of type xstring> is declared. The content of text> must contain valid characters. The sortable byte string is defined as a platform-dependent string in such a way that a size comparison or standard sorting of multiple of these fields produces an order in which the source fields text> are sorted according to the locale> defined in the current text environment>. The text environment is set when an ABAP_ISESS > is opened or by using the statement SET LOCALE>>. If the target field hex> is of type x> and its length is not sufficient for the byte string, an uncatchable exception is raised. If the length is greater than that of the byte string, it is filled with hexadecimal 0 on the right. The sufficient length for all platforms is calculated as 24 times the length of text> plus 24, but can be significantly shorter for some platforms. If hex> is of type xstring>, its length is adapted automatically.
Latest notes: The statement CONVERT TEXT> is mainly intended to fill an index column in internal tables where the column can be used to sort the lines of the table according to a locale. Since internal tables can also be sorted directly according to a locale using the addition AS TEXT > of the statement SORT>>, CONVERT TEXT > is particularly suited for the following cases:
An internal table should be sorted according to a locale and then searched binarily using the statement READ TABLE> or using a table expression>.
An internal table should be sorted more than once according to a locale. Using a sortable byte string ensures better performance than when using the addition AS TEXT>.
Indexes for DDIC database tables should be structured according to a locale.
Textual comparisons are to be made between character-like data objects. NON_V5_HINTS ABAP_HINT_END
ABAP_EXAMPLE_VX5 The characters a> and Z> are compared directly after they have been converted by CONVERT TEXT>. While Z> is in front of a> for most code pages in direct comparisons, the comparison of the converted values returns the expected textual order. See also the executable example > for SORT> for internal tables. ABEXA 00152 ABAP_EXAMPLE_END