[ABAP] Binärdaten (RAW) mit GZIP komprimieren und Base64 codieren

/iwwrk/cl_mgw_workflow_rt_util

TRY.
* Binärdaten
    DATA: lv_xstr TYPE xstring VALUE '54657374737472696E672066C3BC7220646965204B6F6D7072657373696F6E206D697420475A49502E'.
    DATA: lv_xstr_gzip TYPE xstring.

* GZIP komprimieren
    cl_abap_gzip=>compress_binary( EXPORTING raw_in   = lv_xstr
                                   IMPORTING gzip_out = lv_xstr_gzip ).

* Base64 codieren
    DATA(lv_base64_data) = /iwwrk/cl_mgw_workflow_rt_util=>base64_encode( lv_xstr_gzip ).

    WRITE: / lv_base64_data.

  CATCH cx_root INTO DATA(e_txt).
    WRITE: / e_txt->get_text( ).
ENDTRY.

SSFC_BASE64_ENCODE

* Binärdaten
DATA: lv_xstr TYPE xstring VALUE '54657374737472696E672066C3BC7220646965204B6F6D7072657373696F6E206D697420475A49502E'.
DATA: lv_xstr_gzip TYPE xstring.

* GZIP komprimieren
cl_abap_gzip=>compress_binary( EXPORTING raw_in   = lv_xstr
                               IMPORTING gzip_out = lv_xstr_gzip ).

DATA(lv_base64_data) = ||.

* Base64 codieren
CALL FUNCTION 'SSFC_BASE64_ENCODE'
  EXPORTING
    bindata                  = lv_xstr_gzip
  IMPORTING
    b64data                  = lv_base64_data
  EXCEPTIONS
    ssf_krn_error            = 1
    ssf_krn_noop             = 2
    ssf_krn_nomemory         = 3
    ssf_krn_opinv            = 4
    ssf_krn_input_data_error = 5
    ssf_krn_invalid_par      = 6
    ssf_krn_invalid_parlen   = 7
    OTHERS                   = 8.
IF sy-subrc = 0.
  WRITE: / lv_base64_data.
ENDIF.