[ABAP] xstring (Bytes) nach string (Text) wandeln

Variante 1 (cl_abap_conv_in_ce)

DATA: lv_xstr TYPE xstring VALUE '54657374737472696E672066C3BC7220646965204B6F6D7072657373696F6E206D697420475A49502E'.
DATA: lv_str TYPE string.
  
* xstring (binary) -> string (UTF-8)
DATA(o_conv_r) = cl_abap_conv_in_ce=>create( input = lv_xstr encoding = 'UTF-8' ).
o_conv_r->read( IMPORTING data = lv_str ).

WRITE: / lv_str.

Variante 2 (/ui2/cl_abap2json)

DATA: lv_xstr TYPE xstring VALUE '54657374737472696E672066C3BC7220646965204B6F6D7072657373696F6E206D697420475A49502E'.

* xstring -> string (UTF-8)
DATA(lv_str) = /ui2/cl_abap2json=>conv_xstring_to_string( lv_xstr ).

WRITE: / lv_str.

Variante 3 (cl_proxy_service)

DATA: lv_xstr TYPE xstring VALUE '54657374737472696E672066C3BC7220646965204B6F6D7072657373696F6E206D697420475A49502E'.

* xstring (binary) -> string (4110)
DATA(lv_str_res) = cl_proxy_service=>xstring2cstring( lv_xstr ).

WRITE: / lv_str_res.

Variante 4 (ICT_DISPATCH)

DATA: lv_xstr TYPE xstring VALUE '54657374737472696E672066C3BC7220646965204B6F6D7072657373696F6E206D697420475A49502E'.
DATA: lv_string TYPE string.

* xstring (binary) -> string
CALL 'ICT_DISPATCH' ID 'did'    FIELD 'append_xstring_to_string'
                    ID 'source' FIELD lv_xstr
                    ID 'dest'   FIELD lv_string.

WRITE: / lv_string.