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.
XSTRING is used to send files to SAP from web applications using technologies such as BSP or SAP Gateway with OData service.
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:
CALL FUNCTION 'HR_KR_XSTRING_TO_STRING'
in_xstring = lv_xstring
out_string = lv_string.
Second way is using class cl_abap_conv_in_ce.
DATA lo_conv TYPE REF TO cl_abap_conv_in_ce.
CALL METHOD cl_abap_conv_in_ce=>create
encoding = 'UTF-8'
endian = 'L'
ignore_cerr = 'X'
replacement = '#'
input = lv_xstring
conv = lo_conv.
CALL METHOD lo_conv->read
data = lv_string.