Dear SAPLearners, in this blog post i will show the steps to install SSL certificate in S/4 HANA ABAP system.
SSL certificate is needed for a secure and confidential data transmission between servers.
For example if you want to consume REST API service in ABAP provided by 3rd party providers like AWS, Azure and GCP, installation of SSL in ABAP system pertaining to that server is mandatory.
Lets get started. For demo purpose I am using SWAPI-The Star Wars REST API.
1. Obtain the SSL certificate of the REST API provider there are different ways to get the certificate below one among of them.
2. Launch https://swapi.dev/ in browser and click on padlock icon in-front of the url.
3. A certificate window opens like below, click on Copy To File button.
4. A Certificate Export Wizard opens and follow the steps below
5. Finally we have successfully export the SS certificate.🙌
6. Open transaction code STRUST – Trust Manager and select import button under SSL client SSL Client(Anonymous) section. Select the certificate we download in previous step
7. Click on Add to Certificate List button to add the SSL certificate.
8. Congrats! 🙌 we have successfully learners how to install SSL certificate in S/4 HANA ABAP system.
Its time to write an ABAP program to test the SSL and the REST API call. Below is the sample code.
DATA: lv_code TYPE i, lv_url TYPE string, li_client TYPE REF TO if_http_client, lt_errors TYPE TABLE OF string, lv_error_message TYPE string, lv_json_data TYPE string. lv_url = 'https://swapi.dev/api/starships'. cl_http_client=>create_by_url( EXPORTING url = lv_url ssl_id = 'ANONYM' IMPORTING client = li_client ). li_client->send( ). li_client->receive( EXCEPTIONS http_communication_failure = 1 http_invalid_state = 2 http_processing_failed = 3 OTHERS = 4 ). IF sy-subrc <> 0. WRITE: / 'Error Number', sy-subrc, /. MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4. li_client->get_last_error( IMPORTING message = lv_error_message ). SPLIT lv_error_message AT cl_abap_char_utilities=>newline INTO TABLE lt_errors. LOOP AT lt_errors INTO lv_error_message. WRITE: / lv_error_message. ENDLOOP. RETURN. ENDIF. li_client->response->get_status( IMPORTING code = lv_code ). IF lv_code = 200. WRITE: / lv_url, ': OK', icon_checked AS ICON. WRITE: /. lv_json_data = li_client->response->get_cdata( ). WRITE lv_json_data. ENDIF.
and the program output is
You can clearly see that SSL connection is successful and we received JSON data.
Please feel free to comment and let us know your feedback. Subscribe for more updates
If you liked it, please share it! Thanks!
Click here to join our channel and stay updated with the latest tutorials and updates.