* Dateiname der Bilddatei zum hochladen
PARAMETERS: p_fname TYPE file_table-filename OBLIGATORY.
START-OF-SELECTION.
* URL zur Google-API für die Erstellung des QR-Codes
DATA(lv_url) = |http://chart.apis.google.com/chart?chs=200x200&cht=qr&chld=\|1&chl=viele%20lustige%20Zeichen/chart.png|.
TRY.
DATA: o_client TYPE REF TO if_http_client.
* Client-Objekt erzeugen
cl_http_client=>create_by_url( EXPORTING
url = lv_url
IMPORTING
client = o_client ).
IF sy-subrc = 0.
* HTTP GET senden
o_client->send( ).
* Response lesen
o_client->receive( ).
DATA: lv_http_status TYPE i.
DATA: lv_status_text TYPE string.
* HTTP Return Code holen
o_client->response->get_status( IMPORTING
code = lv_http_status
reason = lv_status_text ).
* Wenn Status 200 (Ok)
IF lv_http_status = 200.
* Binärdaten (QR-Code) auslesen
DATA(lv_xdata) = o_client->response->get_data( ).
o_client->close( ).
* xstring -> solix
DATA(it_img_conv_data) = cl_bcs_convert=>xstring_to_solix( iv_xstring = lv_xdata ).
WRITE: / |{ p_fname }.png|.
* Image lokal speichern
cl_gui_frontend_services=>gui_download( EXPORTING
filename = |{ p_fname }.png|
filetype = 'BIN'
bin_filesize = xstrlen( lv_xdata )
CHANGING
data_tab = it_img_conv_data ).
ENDIF.
ENDIF.
CATCH cx_root INTO DATA(e_txt).
WRITE: / e_txt->get_text( ).
ENDTRY.