[ABAP] Base64 codierten String in Binärdaten (RAW) konvertieren und mit GZIP dekomprimieren

/iwwrk/cl_mgw_workflow_rt_util

TRY.
* Base64 String welcher GZIP-komprimierte Binärdaten beinhaltet
    DATA(lv_base64_data) = |C0ktLikuKcrMS1dIO7ynSCElM1XBOz+3oCi1uDgzP08hN7NEwT3KM0APAA==|.

* Base64 decodieren
    DATA(lv_xstr_gzip) = /iwwrk/cl_mgw_workflow_rt_util=>base64_decode( lv_base64_data ).

* Binärdaten
    DATA: lv_xstr TYPE xstring.
    cl_abap_gzip=>decompress_binary( EXPORTING gzip_in = lv_xstr_gzip IMPORTING raw_out = lv_xstr ).

    DATA: lv_str TYPE string.

* xstring (binary) -> string (UTF-8)
    DATA(o_conv) = cl_abap_conv_in_ce=>create( input    = lv_xstr
                                               encoding = 'UTF-8' ).
    o_conv->read( IMPORTING data = lv_str ).

    WRITE: / lv_str.

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

SSFC_BASE64_DECODE

* Base64 String welcher GZIP-komprimierte Binärdaten beinhaltet
DATA(lv_base64_data) = |C0ktLikuKcrMS1dIO7ynSCElM1XBOz+3oCi1uDgzP08hN7NEwT3KM0APAA==|.

* Binärdaten
DATA: lv_xstr TYPE xstring.
DATA: lv_xstr_gzip TYPE xstring.

* Base64 decodieren
CALL FUNCTION 'SSFC_BASE64_DECODE'
  EXPORTING
    b64data                  = lv_base64_data
  IMPORTING
    bindata                  = lv_xstr_gzip
  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.
  cl_abap_gzip=>decompress_binary( EXPORTING gzip_in = lv_xstr_gzip IMPORTING raw_out = lv_xstr ).

  DATA: lv_str TYPE string.

* xstring (binary) -> string (UTF-8)
  DATA(o_conv) = cl_abap_conv_in_ce=>create( input    = lv_xstr
                                             encoding = 'UTF-8' ).
  o_conv->read( IMPORTING data = lv_str ).

  WRITE: / lv_str.
ENDIF.