Skip to Content
Technical Articles
Author's profile photo Meenakshi Dwivedi

How to use RFC adapter in SAP Cloud Platform Integration to execute remote function module on ABAP system

What is RFC?

A remote function call (RFC) is the standard interface used for integrating on-premise ABAP systems to the systems hosted on cloud using SAP cloud connector.

In the SAP system, these functions are provided by the RFC interface system. The RFC interface system enables function calls between two SAP systems, or between an SAP system and an external system.

Synchronous RFC receiver adapter

In the first version of RFC adapter, synchronous RFC (sRFC) is made available for you to execute the function call based on synchronous communication, which means that both the systems must both be available at the time the call is made.

Use case: Use RFC Adapter to execute remote function module on ABAP system

This blog covers the end to end scenario of creating RFC integration flow by using SAP Cloud Platform Integration web UI. It also gives you an insight on how to create RFC destinations via SAP cloud connector in SAP Cloud Platform, setting up additional (necessary) properties in the destination configuration etc. Towards the end of the tutorial you will see a simple use case of invoking request-response method (using Postman Web client tool) for retrieving data from ABAP system (for example flight details) using RFC adapter.

Prerequisite:

Ensure that following prerequisites are met before getting started:

Creating integration flow for RFC adapter

  1. Open browser and enter the URL – https://<tenant_name>.int.sap.hana.ondemand.com/itspaces/
  2. Under Design, select Create to add new package. 
  3. Click Save.
  4. Select your package and go to ARTIFACTS tab.
  5. Choose Add > Integration Flow.
  6. Enter name to create new integration flow artifact and click OK.
  7. Click the new integration flow you have created and click Edit.
  8. Connect Sender to start using HTTPS adapter type.
  9. Under HTTPS, go to Connection tab set the address. For instance, here we set it as “/demo”.
  10. Go to Design Palette and select Call > External Call > Request Reply
  11. Add one receiver and connect Request-Reply call via RFC.
  12. Go to Connection tab under RFC and provide destination name in Name field.

You can create dynamic destinations by using regular expressions (header, property) in the Content Modifier. To do that, you need to first select the Content Modifier in the integration flow. Then go to Message Header and assign corresponding value to the header name as the destination name. Select your RFC adapter and assign dynamic destination by using the expression: ${header/property.<header/property name>}. For example ${header.abc} or ${property.abc} where abc is the value of the header or property.

13. (Optional and applicable to BAPI functions ) Choose Send Confirm Transaction to enable the option if you want to support BAPI functions that require BAPI_TRANSACTION_COMMIT to be invoked implicitly by the RFC receiver adapter.

Ensure the following ABAP functions are whitelisted in Cloud connector before using this option:

  • BAPI_TRANSACTION_COMMIT

  • BAPI_TRANSACTION_ROLLBACK

14. Click Save

 

Use the destination name that is created for you in the subscriber account in HCP. See step 4 of the following section “Creating RFC destination in SCP”.

Creating RFC destination in SCP

    1. Go to https://hana.ondemand.com
    2. Select your tenant account which you would have created while creating cluster.
    3. Go to Connectivity > Destinations.
    4. Create new destination by selecting New Destination.
    5. Enter the details for Name, URL, User, Password and select Type as RFC.
    6. Add additional properties and enter required values as configured in cloud connector:
      • Jco.client.ashost
      • Jco.client.client
      • Jco.client.lang
      • Jco.client.sysnr
      • Jco.destination.pool_capacity (optional)
    7. Select Save.

 

Invoking HTTP endpoint using postman client

Now that you have successfully deployed the integration flow. You can invoke request-response method to retrieve data from ABAP system using RFC adapter.

In this demo, we have used the function module SXIDEMO_AIRL_FLIGHT_CHECKAVAIL to check the number of seats available for the flight for a specific date.

Refer to information on how to generate function module (XML/WSDL file) in the Prerequisite section.

Procedure

    • Invoke the HTTP request URL:
      https://<host:post>/http/IFlow name​
    • Set the method as POST. Provide the necessary inputs in the request body.
    • Use Basic Authorization as header.
    • Sample XML input format to be entered in HTTP Body:
<?xml version="1.0" encoding="UTF-8"?> <ns1:SXIDEMO_AIRL_FLIGHT_CHECKAVAIL xmlns:ns1="urn:sap-com:document:sap:rfc:functions"> <FLIGHT_KEY> <AIRLINEID>AA</AIRLINEID> <CONNECTID>0017</CONNECTID> <FLIGHTDATE>2017-05-01</FLIGHTDATE> </FLIGHT_KEY> </ns1:SXIDEMO_AIRL_FLIGHT_CHECKAVAIL>

Result: You can view the number of seat available for the flight on the specified date.

Assigned Tags

      20 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Karina Krupina
      Karina Krupina

       

      Hi Meenakshi,

      thanks for your post.

      In your example you're using RFC adapter in an artifact of type integration flow. Is RFC adapter also supposed to work fine in an artifact of type oData service? Or is there a limitation and one has to create a service as integration flow with RFC adapter, and then consume this service via HTTP adapter in oData service?

       

      thanks and regards

      Karina

      Author's profile photo Meenakshi Dwivedi
      Meenakshi Dwivedi
      Blog Post Author

       

      Hi Karina,

      RFC adapter is supported only in an artifact type “Integration Flow”.

      REgards,

      Meenakshi

      Author's profile photo Denise Landers
      Denise Landers

      Hi Meenakshi,

      When making a REST call to invoke an iFlow that uses the RFC adapter to call a BAPI, how do we determine the correct XML request format of the message body?

      For example; when calling BAPI_PROJECT_GETINFO, the request XML looks like:

      <?xml version="1.0" encoding="UTF-8"?>
      <ns1:BAPI_PROJECT_GETINFO xmlns:ns1="urn:sap-com:document:sap:rfc:functions">
         <PROJECT_DEFINITION>'T-20303'</PROJECT_DEFINITION>
         <WITH_ACTIVITIES>Y</WITH_ACTIVITIES>
         <WITH_MILESTONES>Y</WITH_MILESTONES>
         <WITH_SUBTREE/>
      </ns1:BAPI_PROJECT_GETINFO>

       

      When calling BAPI_NETWORK_GETINFO, we assumed from looking at the SE37 BAPI call that the XML format would look like below, however that is not working.

      <?xml version="1.0" encoding="UTF-8"?>
      <ns1:BAPI_NETWORK_GETINFO xmlns:ns1="urn:sap-com:document:sap:rfc:functions">
          <TABLES>
              <I_NETWORK_LIST>
                  <NETWORK>000000909139</NETWORK>
              </I_NETWORK_LIST>
          </TABLES>
      </ns1:BAPI_NETWORK_GETINFO>

      We have tried with and without the <TABLES> node and with and without the leading 0's.
      We are not getting an errors in the logs. We are getting back an empty <E_NETWORK> node.  (The network does exist.)

      <?xml version="1.0" encoding="UTF-8" standalone="no"?>
      <rfc:BAPI_NETWORK_GETINFO.Response xmlns:rfc="urn:sap-com:document:sap:rfc:functions">
          <RETURN>
              <TYPE/>
              <ID/>
              <NUMBER>000</NUMBER>
              <MESSAGE/>
              <LOG_NO/>
              <LOG_MSG_NO>000000</LOG_MSG_NO>
              <MESSAGE_V1/>
              <MESSAGE_V2/>
              <MESSAGE_V3/>
              <MESSAGE_V4/>
          </RETURN>
          <E_ACTIVITY/>
          <E_ACTIVITY_ELEMENT/>
          <E_ACTIVITY_MILESTONE/>
          <E_COMPONENT/>
          <E_MESSAGE_TABLE/>
          <E_NETWORK/>
          <E_RELATION/>
          <I_NETWORK_LIST/>
      </rfc:BAPI_NETWORK_GETINFO.Response>

      Is there a tool or utility to use that would describe the required request format (or xsd)?

      Thank you,
      Denise

      Author's profile photo Meenakshi Dwivedi
      Meenakshi Dwivedi
      Blog Post Author

       

      Hi Denise,

      Please try using ESR tool to generate XSD.

      I have documented the steps @ https://help.sap.com/viewer/DRAFT/368c481cd6954bdfa5d0435479fd4eaf/DEV/en-US/57a6b6ede47c449aa0808ff9695aec49.html

      Let me  know if you have further queries.

      REgards,

      Meenakshi

      Author's profile photo Markus Discher
      Markus Discher

      Meenakshi Dwivedi

      Your Link does not work. It sais 403. It sais DRAFT in the url so probably thats not a public version. Can you provide a working url please? I am stuck with the same problem.

      Do you have an example payload for an rfc call with a table?

      Best regards and thanks in advance

      Author's profile photo Wulfrano Moreno
      Wulfrano Moreno

      In case someone needs this information, for the example in the question, the correct structure to send a table through RFC adapter in CPI would be the next:

      <?xml version="1.0" encoding="UTF-8"?>
      <ns1:BAPI_NETWORK_GETINFO xmlns:ns1="urn:sap-com:document:sap:rfc:functions">
              <I_NETWORK_LIST>
      	   <item>
                  	<NETWORK>000000909139</NETWORK>
      	   </item>
              </I_NETWORK_LIST>
      </ns1:BAPI_NETWORK_GETINFO>

       

      Basically the table node must have inside "item" nodes for every register you want to send, hope it helps to someone.

      As for the XSD there are a lot of tools, one that I use is freeformatter, you just have to paste the XML and it can generate the XSD, here is the link https://www.freeformatter.com/xsd-generator.html

       

       

       

      Author's profile photo David Lawn
      David Lawn

      Hello

      can you please tell me how to do this

      1. Open browser and enter the URL – https://<tenant_name>.int.sap.hana.ondemand.com/itspaces/

      I have a trial user Sxxxxxxxtrial for Hana SAP Cloud Platform.

      I do not know what <tenant_name> should be.

      Thank you.

       

      Author's profile photo Former Member
      Former Member

      Hi Meenakshi,

      Thank you for this informative blog. I am pretty new to HCI and I am working on a scenario where my RFC receiver adapter is supposed to just fetch the status of some assets and then I will be sending that to the cloud.

      I have also created a query on the same. Can you please look into the same and let me know your suggestions.

      https://answers.sap.com/questions/448964/exception-in-rfc-adapter-in-cloud-platform-integra.html

       

      Regards

      Amitabh

      Author's profile photo Former Member
      Former Member

       

      Hi Meenakshi,

      Request for your help with this scenario. I am trying exactly as you have shown. But when I send the request from postman editor I am getting an error. Please suggest what I could have missed.

       

      The Response is as below.

       

      My other iFlows are running fine. Please suggest.

      Regards

      Amitabh

       

      Author's profile photo Former Member
      Former Member

      Hi Meenakshi,

      Closing this question. I could get the result. However I have a query here. Can I push the received data from the RFC into a table in Cloud?

       

      Thanks

      Amitabh

      Author's profile photo Frederick-Claud Dimmer
      Frederick-Claud Dimmer

      Great article! It saved me a lot of time. Regards Frederick

      Author's profile photo Juan Rios
      Juan Rios

      hello, how i can get the property xsd from the FM without using ESR?, i am having an error in that part.

      Author's profile photo Varun Khetan
      Varun Khetan

      Hi Meenakshi,

      I have created an RFC destination in Cloud Connector, and its reachable as well.

       

      But when i am creating an RFC destination in Cloud Platform Integration, it is giving me below error.

      "Failure reason: "Backend is not available in the list of defined system mappings in Cloud connector"

       

      Sorry but i am not able to attach images for my configuration 🙁

       

      Can you please advise if you might have encountered similar issue and have fixed it.

       

      Regards,

      Varun

       

      Author's profile photo Varun Khetan
      Varun Khetan

      Hi Meenakshi,

      Issue is solved.

      Thanks.

      Varun

      Author's profile photo Frederik Pena-Tolivia
      Frederik Pena-Tolivia

      Hi Varun,
      How did you fix it ?

      Facing the same error
      Kind regards,

      Frederik

      Author's profile photo Sindhuja Jayapandiyan
      Sindhuja Jayapandiyan

      Hi Meenakshi Dwivedi ,

       

      I am trying to connect to ABAP system from Cloud integration. Configured Cloud connector and Destination in BPT Cockpit level as prescribed. It is reachable in cloud connector. But when I deploy iflow, is is showing below error.

      Error Details

      com.sap.it.rt.adapter.rfc.exceptions.RFCLibraryException: <?xml version="1.0" encoding="UTF-8" standalone="no"?><rfc:RFCExceptions xmlns:rfc="urn:sap-com:document:sap:rfc:functions"><Exceptions> <E1>getDocument Failed</E1> </Exceptions></rfc:RFCExceptions>
      Could you please advice on this.
      Regards,
      Sindhuja.
      Author's profile photo Tikeer Guo
      Tikeer Guo

      Hi Sindh

      Is the issue solved? And how to solve it?

      Best regards.

      Author's profile photo Sindhuja Jayapandiyan
      Sindhuja Jayapandiyan

      Hi  Tikeer Guo,

       

      Issue got resolved. It was related to data error-the input request xml was having namespace and extension issue. Once it was changed, able to retrieve data from backend system successfully.

       

      Regards,

      Sindhuja.

      Author's profile photo Zameer Ahamad
      Zameer Ahamad

      Hi Sindhuja,

      We are facing below error for newly created RFC for the existing application, could you help us what could be the reason for the below error.

      com.sap.it.rt.adapter.http.api.exception.HttpResponseException: An internal server error occured: <?xml version="1.0" encoding="UTF-8" standalone="no"?><rfc:RFCExceptions xmlns:rfc="urn:sap-com:document:sap:rfc:functions"><Exceptions> <E1>getDocument Failed</E1>

      </Exceptions></rfc:RFCExceptions>. The MPL ID for the failed message is : AGC2GRK5uZ4Yjmr9PbGFhqJb5EGa For more details please check tail log.

      We have currently P1 incident issue opened for this, we are unable to find the  root cause, everything is fine interms of connectivity from CPI to ECC RFC call through cloud connector.

       

      Could you help us or provided some inputs to start troubleshooting this issue.Thanks in advance.

      your help will be appreciated.

       

      Regards

      Zameer Ahamad

      Author's profile photo Sulbh Kalra
      Sulbh Kalra

      Hi Meenakshi Dwivedi 

      In production system, while calling RFC adapter using standard BAPI from HTTP endpoint, we are getting expected result whereas when we use custom Z FM (Remote Enabled) we are getting "Error Getting Function".

      We tried multiple Z FMs which are remote enabled, all are giving same error.

      Further to note same Z Function in lower environment(Test system) is working as expected.

      Success%20-%20RDC%20Adapter%20with%20Standard%20RFC

      Success - RDC Adapter with Standard RFC

      Failed%20RFC%20Adapter

      Failed RFC Adapter