> For the complete documentation index, see [llms.txt](https://documentation.renda.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://documentation.renda.io/integrations/sap-on-premise.md).

# SAP On-premise

## Import Renda SSL Certificate

{% hint style="warning" %}
Renda is hosted on AWS. You will need to install AWS root certificate in your SAP landscape to enable communication between your SAP system and Renda APIs.&#x20;

Please remember to import the SSL certificate across all the systems in your SAP landscape
{% endhint %}

{% file src="/files/9pbQSH2n10G0uHsS1ztv" %}

1. Download AWS Root - Renda SSL certificate&#x20;
2. Go to transaction STRUST
3. Go to SSL Client SSL Client(Standard) and select entry corresponding to your system
4. Import the certificate
5. Click on "Add to certificate list"
6. Save

## Setup SM59 Connection

1. Login into Renda developer portal
2. Subscribe to HTML->PDF service
3. Copy API Service URL to notepad
4. Go to transaction SM59
   1. Create a new HTTP Connection to External Server - Type G
   2. Key in **RENDA.IO** in RFC Destination field
   3. Enter description as **Renda.io connection for HTML transformation**
   4. Under Technical Settings tab - Paste region specific API Service URL
   5. Under Logon & Security -> Security Options - Status of Secure Protocol->SSL is **active**&#x20;
   6. Enter Service No. as **443**
   7. Test Connection&#x20;

{% hint style="info" %}
You should receive a HTTP 200 success code if everything is setup successfully.
{% endhint %}

{% hint style="warning" %}
Please remember to whitelist **API Service URL** from within your corporate firewall. This will enable outbound calls to be made from your SAP system to Renda engine in the cloud.
{% endhint %}

## Invoking REST API

The following code demonstrates how Renda can be invoked from ABAP function to convert HTML output  to PDF document

{% tabs %}
{% tab title="ABAP Code - To Convert HTML output to PDF document" %}

```java
FUNCTION zgenerate_pdf.
*"----------------------------------------------------------------------
*"*"Local Interface:
*"  IMPORTING
*"     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
*"  EXPORTING
*"     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_http_rc     TYPE i,
        lv_response    TYPE string,
        lv_json        TYPE /ui2/cl_json=>json,
        lr_data        TYPE REF TO data.
*
  FIELD-SYMBOLS: <data>  TYPE data,
                 <field> TYPE any.
*
* Setup IF_HTTP_Client object
*
  CALL METHOD cl_http_client=>create_by_destination
    EXPORTING
      destination        = im_rfcdest
    IMPORTING
      client             = lo_http_client
    EXCEPTIONS
      argument_not_found = 1
      plugin_not_active  = 2
      internal_error     = 3
      OTHERS             = 4.
*
  IF sy-subrc IS NOT INITIAL.
    ex_mess = 'Error creating new IF_HTTP_Client object. Process aborted.'.
    ex_subrc = 4.
    RETURN.
  ENDIF.
*
* Set protocol version
*
  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(
      name  = 'Accept'
      value = 'application/pdf' ).
*
  lo_http_client->request->set_header_field(
      name  = 'Content-Type'
      value = 'application/x-www-form-urlencoded' ).
*
  lo_http_client->request->set_header_field(
      name  = 'x-api-key'
      value = im_api_key ).
*
* Set form fields/attributes
*
  lo_http_client->request->if_http_entity~set_form_field(
    name   = 'inputPayload'
    value  = im_html ).
*
  IF im_encryption_key IS NOT INITIAL.
*
    lo_http_client->request->if_http_entity~set_form_field(
      name   = 'encryptionKey'
      value  = im_encryption_key ).
*
  ENDIF.
*
  IF im_landscape IS NOT INITIAL.
*
    lo_http_client->request->if_http_entity~set_form_field(
      name   = 'landscape'
      value  = im_landscape ).
*
  ENDIF.
*
  IF im_format IS NOT INITIAL.
*
    lo_http_client->request->if_http_entity~set_form_field(
      name   = 'format'
      value  = im_format ).
*
  ENDIF.
*
  IF im_margin_top IS NOT INITIAL.
*
    lo_http_client->request->if_http_entity~set_form_field(
      name   = 'marginTop'
      value  = im_margin_top ).
*
  ENDIF.
*
  IF im_margin_right IS NOT INITIAL.
*
    lo_http_client->request->if_http_entity~set_form_field(
      name   = 'marginRight'
      value  = im_margin_right ).
*
  ENDIF.
*
  IF im_margin_bottom IS NOT INITIAL.
*
    lo_http_client->request->if_http_entity~set_form_field(
      name   = 'marginBottom'
      value  = im_margin_bottom ).
*
  ENDIF.
*
  IF im_margin_left IS NOT INITIAL.
*
    lo_http_client->request->if_http_entity~set_form_field(
      name   = 'marginLeft'
      value  = im_margin_left ).
*
  ENDIF.
*
  lo_http_client->request->set_method( 'POST' ).
*
  lo_http_client->propertytype_logon_popup = lo_http_client->co_disabled.
*
* Send request
*
  CALL METHOD lo_http_client->send
    EXPORTING
      timeout                    = 60   " 15 Seconds
    EXCEPTIONS
      http_communication_failure = 1
      http_invalid_state         = 2.
*
  IF sy-subrc IS NOT INITIAL.
*
    ex_mess = 'HTTP Post error. Process aborted'.
    ex_subrc = 4.
*
    CALL METHOD lo_http_client->close
      EXCEPTIONS
        http_invalid_state = 1
        OTHERS             = 2.
*
    FREE lo_http_client.
    RETURN.
*
  ENDIF.
*
* Read the Response
*
  CALL METHOD lo_http_client->receive
    EXCEPTIONS
      http_communication_failure = 1
      http_invalid_state         = 2
      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( ).
*
  IF lv_http_rc NE '200'.
*
* Get error message back from Renda
*
    ex_subrc = 4.
    lv_json = lv_response.
    lr_data = /ui2/cl_json=>generate( json = lv_json ).
*
    IF lr_data IS BOUND.
      ASSIGN lr_data->* TO <data>.
      ASSIGN COMPONENT 'MESSAGE' OF STRUCTURE <data> TO <field>.
      IF <field> IS ASSIGNED.
        lr_data = <field>.
        ASSIGN lr_data->* TO <data>.
        ex_mess = <data>.
      ENDIF.
    ENDIF.
*
  ELSE.
*
    ex_pdf = lo_http_client->response->get_data( ).
*
  ENDIF.
*
  CALL METHOD lo_http_client->close
    EXCEPTIONS
      http_invalid_state = 1
      OTHERS             = 2.
*
  FREE lo_http_client.
*
ENDFUNCTION.
```

{% endtab %}
{% endtabs %}
