[ABAP] Binärdaten (xstring) zu String wandeln (xstring -> string)

Variante 1 (xstring -> string)

* Binärdaten als xstring
DATA(lv_xstring) = CONV xstring( 'A0B0C0FF' ).
* xstring -> string
DATA(lv_string) = CONV string( lv_xstring ).

WRITE: / lv_string.

Variante 2 (String als formatierten Hexcode ausgeben)

DATA: lv_mime_type TYPE string.
DATA: lv_image_bytes TYPE xstring.
DATA: it_text80 TYPE STANDARD TABLE OF text80 WITH DEFAULT KEY.

TRY.
* Ein paar Bytes holen: Screenshot aufnehmen
    cl_gui_frontend_services=>get_screenshot( IMPORTING
                                                mime_type_str = lv_mime_type
                                                image         = lv_image_bytes ).

* xstring -> string
    DATA(lv_string) = CONV string( lv_image_bytes ).

* formatierte Ausgabe (80 Zeichen Breite)
    CALL FUNCTION 'SWA_STRING_TO_TABLE'
      EXPORTING
        character_string = lv_string
      IMPORTING
        character_table  = it_text80.

    LOOP AT it_text80 ASSIGNING FIELD-SYMBOL(<t>).
      WRITE: / <t>.
    ENDLOOP.

  CATCH cx_root INTO DATA(e_txt).
ENDTRY.