SAP BTP CPI iflow end to end integration using RFC Adapter – Part 5

A) Create XML transform.  For this we create a custom structure as shown belowB) Tcode XSLT_TOOL   use the wizrd button and create a root node as shown below  C) change the source code so that we have the name space as shown below 3 Cloud connector settings should as shown below ( from cloud to onPremise) for the location id that points your BTP sub client instance.Now add the source to the FM created in Step 1 as shown below                                                Check the connection is working                                                                                                   4.  BTP create a destination in BTP->Connectivity=>destinations and create new destination as shown below                                                                                                                              check that the connection is working fine.                                                                                     5  BTP integration suite flow with http inbound invokes the RFC using RFC adapter via the destination created in the previous step and the booking confirmation email as shown below      HTTP sending settings as shown below, RFC and email settings are shown in the order below  NPLRFC is the destination that was created in the earlier step.   Email Adapter settings are as shown          Save and deploy the integration  and note the url                                                                         6  Custom FM to invoke the integration created in the previous step – The code is as show below FUNCTION zcall_cpi_rfcbookingconfirm.
*”———————————————————————-
*”*”Local Interface:
*”  IMPORTING
*”     VALUE(I_CARRID) TYPE  S_CARR_ID
*”     VALUE(I_CONNID) TYPE  S_CONN_ID
*”     VALUE(I_FLDATE) TYPE  DATS
*”     VALUE(I_BOOKID) TYPE  S_BOOK_ID
*”     REFERENCE(I_MAINURL) TYPE  STRING
*”     REFERENCE(I_EXRURL) TYPE  STRING
*”     REFERENCE(I_USERNAME) TYPE  STRING
*”     REFERENCE(I_PASSWORD) TYPE  STRING
*”———————————————————————-

DATAlo_json        TYPE REF TO cl_clb_parse_json,
lv_url         TYPE string,
lo_rest_client TYPE REF TO cl_rest_http_client,
lo_response    TYPE REF TO if_rest_entity,
lo_request     TYPE REF TO if_rest_entity,
lo_sql         TYPE REF TO cx_sy_open_sql_db,
status         TYPE  string,
reason         TYPE  string,
response       TYPE  string,
content_length TYPE  string,
location       TYPE  string,
content_type   TYPE  string,
lv_status      TYPE  i,
http_status    TYPE        string,
lv_xml_string  TYPE xstring,
lv_body        TYPE string,
lv_newdate     TYPE char10.

CALL FUNCTION ‘CONVERSION_EXIT_PDATE_OUTPUT’
EXPORTING
input  i_fldate
IMPORTING
output lv_newdate.

DATAls_bookrec  TYPE zrfcboook.

ls_bookreci_carrid  i_carrid.
ls_bookreci_connid  i_connid.
ls_bookreci_fldate lv_newdate.
ls_bookreci_bookid i_bookid.

TRY.

cl_http_client=>create_by_url(
EXPORTING
url                i_mainurl
IMPORTING
client             DATA(lo_http_client)
EXCEPTIONS
argument_not_found 1
plugin_not_active  2
internal_error     3
OTHERS             ).

CALL TRANSFORMATION  ztr_sbook_key
SOURCE zget_flight_booking_data =  ls_bookrec
RESULT XML lv_xml_string.

CALL METHOD cl_abap_conv_in_ce=>create
EXPORTING
input lv_xml_string
RECEIVING
conv  DATA(lr_conv).

lr_conv->read(
IMPORTING
data    lv_body ).

lo_http_client->propertytype_logon_popup lo_http_client->co_disabled.

CALL METHOD lo_http_client->authenticate
EXPORTING
username i_username
password i_password.

lo_http_client->request->set_methodif_http_request=>co_request_method_post ).

CREATE OBJECT lo_rest_client
EXPORTING
io_http_client lo_http_client.
lo_http_client->request->set_versionif_http_request=>co_protocol_version_1_0 ).

IF lo_http_client IS BOUND AND lo_rest_client IS BOUND.
lv_url i_exrurl.
“lv_url = ‘/http/BookingConfirm’.
cl_http_utility=>set_request_uri(
EXPORTING
request lo_http_client->request    ” HTTP Framework (iHTTP) HTTP Request
uri     lv_url
).

lo_request lo_rest_client->if_rest_client~create_request_entity).
lo_request->set_content_typeiv_media_type if_rest_media_type=>gc_appl_json ).
lo_request->set_string_datalv_body ).

lo_rest_client->if_rest_resource~postlo_request ).

lo_response lo_rest_client->if_rest_client~get_response_entity).
http_status lv_status lo_response->get_header_field‘~status_code’ ).
reason lo_response->get_header_field‘~status_reason’ ).
content_length lo_response->get_header_field‘content-length’ ).
location lo_response->get_header_field‘location’ ).
content_type lo_response->get_header_field‘content-type’ ).
response lo_response->get_string_data).

ENDIF.

CATCH cx_root INTO DATA(lr_exc).
DATA(lv_messagelr_exc->get_text).
WRITE:/ lv_message.
ENDTRY.
ENDFUNCTION.                                                                                                                            7 Create the implicit enhancement that is invoked on Flight Booking Tcode as shown below. The code is very similar to the code  in Part 4 odata adapter except for 2 parameters name FLDATE and I_extrul which now points to the new iflow to invoke the RFC  8 Create a new Booking using the TCODE BC_GLOBAL_SBOOK_CREA and check the email showing the booking confirmation details from the RFC as shown below    Email showing the booking confirmation    As seen we can use the existing RFC FM that are already in the SAP System or convert FM to RFC FM and use the RFC adapter to provide efficiency in processing