Variante 1 (SCMS_BINARY_TO_XSTRING)
DATA: it_bin_data TYPE STANDARD TABLE OF raw255. " iTab mit Binärdaten
DATA: lv_bytes TYPE i. " reale Länge der Daten in Bytes
DATA: lv_xstr_result TYPE xstring.
...
CALL FUNCTION 'SCMS_BINARY_TO_XSTRING'
EXPORTING
input_length = lv_bytes
IMPORTING
buffer = lv_xstr_result
TABLES
binary_tab = it_bin_data
EXCEPTIONS
failed = 1
OTHERS = 2.
IF sy-subrc NE 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
Variante 2 (cl_swf_utl_convert_xstring)
DATA: lv_size TYPE i.
DATA: it_raw_data TYPE STANDARD TABLE OF raw255.
cl_gui_frontend_services=>gui_upload( EXPORTING
filename = 'c:\temp\binaryfile.dat'
filetype = 'BIN'
read_by_line = space
IMPORTING
filelength = lv_size
CHANGING
data_tab = it_raw_data ).
DATA(lv_xlsx_str) = cl_swf_utl_convert_xstring=>table_to_xstring( i_table = it_raw_data
i_size = lv_size ).
Variante 3 (cl_scp_change_db)
DATA: lv_size TYPE i.
DATA: it_raw_data TYPE STANDARD TABLE OF raw255.
DATA: lv_xstr_result TYPE xstring.
cl_gui_frontend_services=>gui_upload( EXPORTING
filename = 'c:\temp\binaryfile.dat'
filetype = 'BIN'
read_by_line = space
IMPORTING
filelength = lv_size
CHANGING
data_tab = it_raw_data ).
cl_scp_change_db=>xtab_to_xstr( EXPORTING
im_xtab = it_raw_data
im_size = lv_size
IMPORTING
ex_xstring = lv_xstr_result ).
Variante 4 (cl_bcs_convert)
* solix -> xstring
DATA: lv_size TYPE i.
DATA: it_raw_data TYPE solix_tab.
cl_gui_frontend_services=>gui_upload( EXPORTING
filename = 'c:\temp\binaryfile.dat'
filetype = 'BIN'
read_by_line = space
IMPORTING
filelength = lv_size
CHANGING
data_tab = it_raw_data ).
DATA(lv_xstr_result) = cl_bcs_convert=>solix_to_xstring( it_solix = it_raw_data ).
Variante 5 (cl_abap_conv_obj)
DATA: it_bin_data TYPE raw255. " iTab mit Binärdaten
DATA: lv_bytes TYPE i. " reale Länge der Daten in Bytes
...
DATA: lv_xstr_line TYPE xstring.
DATA: lv_xstr_result TYPE xstring.
* RAW (binary) -> xstring
DATA(o_conv) = NEW cl_abap_conv_obj( ).
LOOP AT it_bin_data ASSIGNING FIELD-SYMBOL(<l>).
* Zeile konvertieren
o_conv->convert( EXPORTING
inbuff = <l>
outbufflg = 65535 " max. Zeilenlänge in it_bin_data
IMPORTING
outbuff = lv_xstr_line ).
* Zeilen zusammenbauen
CONCATENATE lv_xstr_result lv_xstr_line INTO lv_xstr_result IN BYTE MODE.
ENDLOOP.
* evtl. Rest von xstring abschneiden, für reale Länge der Daten
lv_xstr_result = lv_xstr_result(lv_bytes).