XSTRING is predefined byte-like ABAP type with variable length. This type ensures dynamic allocation of memory. Its value is a sequence of bytes that equals its hexadecimal value as shows screenshot from ABAP debugger.
Usage
XSTRING is used to send files to SAP from web applications using technologies such as BSP or SAP Gateway with OData service.
Conversions
Mostly, we need to convert XSTRING into different ABAP data types to use it as importing parameter to different function modules and methods.
a) XSTRING to SOLIX
This conversion is described in article How to store file incoming as XSTRING in SAP.
b) XSTRING to STRING
There are few ways how to convert xstring to string. This is most convenient way:
1 2 3 4 5 |
CALL FUNCTION 'HR_KR_XSTRING_TO_STRING' EXPORTING in_xstring = lv_xstring IMPORTING out_string = lv_string. |
Second way is using class cl_abap_conv_in_ce.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
DATA lo_conv TYPE REF TO cl_abap_conv_in_ce. CALL METHOD cl_abap_conv_in_ce=>create EXPORTING encoding = 'UTF-8' endian = 'L' ignore_cerr = 'X' replacement = '#' input = lv_xstring RECEIVING conv = lo_conv. CALL METHOD lo_conv->read IMPORTING data = lv_string. |