*"----------------------------------------------------------------------
*" VALUE(IM_RFCDEST) TYPE RFCDEST
*" VALUE(IM_API_KEY) TYPE STRING
*" VALUE(IM_HTML) TYPE STRING
*" VALUE(IM_ENCRYPTION_KEY) TYPE STRING OPTIONAL
*" VALUE(IM_LANDSCAPE) TYPE STRING OPTIONAL
*" VALUE(IM_FORMAT) TYPE STRING OPTIONAL
*" VALUE(IM_MARGIN_TOP) TYPE STRING OPTIONAL
*" VALUE(IM_MARGIN_RIGHT) TYPE STRING OPTIONAL
*" VALUE(IM_MARGIN_BOTTOM) TYPE STRING OPTIONAL
*" VALUE(IM_MARGIN_LEFT) TYPE STRING OPTIONAL
*" VALUE(EX_SUBRC) TYPE SYSUBRC
*" VALUE(EX_MESS) TYPE STRING
*" VALUE(EX_PDF) TYPE XSTRING
*"----------------------------------------------------------------------
DATA: lo_http_client TYPE REF TO if_http_client,
lv_json TYPE /ui2/cl_json=>json,
lr_data TYPE REF TO data.
FIELD-SYMBOLS: <data> TYPE data,
* Setup IF_HTTP_Client object
CALL METHOD cl_http_client=>create_by_destination
IF sy-subrc IS NOT INITIAL.
ex_mess = 'Error creating new IF_HTTP_Client object. Process aborted.'.
lo_http_client->request->set_version( if_http_request=>co_protocol_version_1_1 ).
* Set request header fields
lo_http_client->request->set_header_field(
value = 'application/pdf' ).
lo_http_client->request->set_header_field(
value = 'application/x-www-form-urlencoded' ).
lo_http_client->request->set_header_field(
* Set form fields/attributes
lo_http_client->request->if_http_entity~set_form_field(
IF im_encryption_key IS NOT INITIAL.
lo_http_client->request->if_http_entity~set_form_field(
value = im_encryption_key ).
IF im_landscape IS NOT INITIAL.
lo_http_client->request->if_http_entity~set_form_field(
IF im_format IS NOT INITIAL.
lo_http_client->request->if_http_entity~set_form_field(
IF im_margin_top IS NOT INITIAL.
lo_http_client->request->if_http_entity~set_form_field(
IF im_margin_right IS NOT INITIAL.
lo_http_client->request->if_http_entity~set_form_field(
value = im_margin_right ).
IF im_margin_bottom IS NOT INITIAL.
lo_http_client->request->if_http_entity~set_form_field(
value = im_margin_bottom ).
IF im_margin_left IS NOT INITIAL.
lo_http_client->request->if_http_entity~set_form_field(
value = im_margin_left ).
lo_http_client->request->set_method( 'POST' ).
lo_http_client->propertytype_logon_popup = lo_http_client->co_disabled.
CALL METHOD lo_http_client->send
timeout = 60 " 15 Seconds
http_communication_failure = 1
IF sy-subrc IS NOT INITIAL.
ex_mess = 'HTTP Post error. Process aborted'.
CALL METHOD lo_http_client->close
CALL METHOD lo_http_client->receive
http_communication_failure = 1
http_processing_failed = 3.
lo_http_client->response->get_status( IMPORTING code = lv_http_rc ).
lo_http_client->response->get_status( IMPORTING reason = ex_mess ).
lv_response = lo_http_client->response->get_cdata( ).
* Get error message back from Renda
lr_data = /ui2/cl_json=>generate( json = lv_json ).
ASSIGN lr_data->* TO <data>.
ASSIGN COMPONENT 'MESSAGE' OF STRUCTURE <data> TO <field>.
ASSIGN lr_data->* TO <data>.
ex_pdf = lo_http_client->response->get_data( ).
CALL METHOD lo_http_client->close