Code: Alles auswählen.
class base64_converter definition.
public section.
class-methods convert_to_base64
importing
bapi_mepoitem type bapi_mepoitem
returning value(result) TYPE string.
private section.
class-methods is_utf16
returning value(unicode) type sap_bool.
endclass.
class base64_converter implementation.
method convert_to_base64.
DATA: struct_descr TYPE REF TO cl_abap_view_offlen,
hex_bapi_mepoitem TYPE xstring.
IF is_utf16( ) = abap_true.
struct_descr = cl_abap_view_offlen=>create_unicode16_view(
bapi_mepoitem ).
ELSE.
struct_descr = cl_abap_view_offlen=>create_legacy_view(
bapi_mepoitem ).
ENDIF.
data(hex_converter) = cl_abap_conv_out_ce=>create( ).
hex_converter->convert_struc( EXPORTING data = bapi_mepoitem view = struct_descr
IMPORTING buffer = hex_bapi_mepoitem ).
result = cl_http_utility=>encode_x_base64( hex_bapi_mepoitem ).
endmethod.
method is_utf16.
DATA: codepage TYPE cpcodepage.
CALL FUNCTION 'SCP_CODEPAGE_FOR_LANGUAGE'
EXPORTING
language = sy-langu
IMPORTING
codepage = codepage.
IF codepage(1) = '1'.
unicode = abap_false.
ELSE.
unicode = abap_true.
ENDIF.
endmethod.
endclass.
Code: Alles auswählen.
ls_extension+30(960) = base64_converter=>convert_to_base64( ls_bapi_mepoitem ).
Code: Alles auswählen.
data: ls_alternativstruktur type alternativstruktur.
MOVE-CORRESPONDING bapi_te_mepoitem to ls_alternativstruktur.
ls_extension-structure = 'ALTERNATIVSTRUKTUR'.
ls_extension+30 = ls_alternativstruktur.