ABAPCONVERT_TEXT - CONVERT TEXT
General Material Data PERFORM Short ReferenceThis documentation is copyright by SAP AG.
CONVERT TEXT
Syntax
CONVERT TEXT text INTO SORTABLE CODE hex.
Effect
The content of the operand text is converted to a sortable byte string and the result is assigned to the variable hex. The data object text itself remains unchanged. text is acharacter-like expression position.
The operand text must be of type c or string and the data object hex mustbe byte-like. The content of text must contain valid characters. The sortable byte string isdefined by platform such that a size comparison or standard sort of several of these fields produces an order in which the source fields text are sorted by thelocale defined in the currenttextenvironment. The text environment is set when an internal session is opened or by using the statement SET LOCALE.
If the data object hex is of type x and its length is not sufficient for the byte string,an exception that cannot be handled is raised. If the length is greater than that of the byte string,it is filled with hexadecimal 0 on the right. The minimum length for all platforms is calculated as24 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.
Notes
- For the CONVERT TEXT statement to work, theprofile parameterinstall/collate/active cannot have the value 0.
- The CONVERT TEXT statement is designed to fill an index column (in internal tables orextracts)by which the rows of the table or extracts can be sorted by locale. Since internal tables and extractscan also be sorted by locale directly by using the AS TEXT addition of the SORTstatement, CONVERT TEXT is especially useful in the following cases:
- If an internal table is sorted by locale and then subjected to a binary search using the statement READ TABLE.
- An internal table or extract is to be sorted more than once by locale. Using a sortable byte string ensures better performance than when using the AS TEXT addition.
- Indices for database tables are to be structured in accordance with a locale.
- Textual comparisons are to be made between character-like data objects.
Example
The characters "a" and "Z" are compared directly after they have been converted by CONVERT TEXT.While "Z" is in front of "a" for the majority of code pages in direct comparisons, the comparison of the converted values returns the expected textual order. See also theexample for SORT for internal tables.
DATA: ax TYPE xstring,
zx TYPE xstring.
IF 'a' > 'Z'.
WRITE / `'a' > 'Z'`.
ELSE.
WRITE / `'a' < 'Z'`.
ENDIF.
CONVERT TEXT: 'a' INTO SORTABLE CODE ax,
'Z' INTO SORTABLE CODE zx.
IF ax > zx.
WRITE / `'a' > 'Z'`.
ELSE.
WRITE / `'a' < 'Z'`.
ENDIF.
Exceptions
Non-Catchable Exceptions
- Cause: One of the operands has an invalid data type.
Runtime Error: CONVERT_TEXT_BAD_OP - Cause: The source field has invalid content.
Runtime Error: CONVERT_TEXT_BAD_SRC - Cause: The target field is too small.
Runtime Error: CONVERT_TEXT_DEST_TOO_SHORT
RFUMSV00 - Advance Return for Tax on Sales/Purchases CL_GUI_FRONTEND_SERVICES - Frontend Services
This documentation is copyright by SAP AG.
Length: 5445 Date: 20120522 Time: 041110 triton ( 210 ms )






