Skip to Content
Technical Articles
Author's profile photo Andre Fischer

How to call a remote function module in your on-premise SAP system from SAP Cloud Platform – ABAP Environment


  • 26.03.2019 added the missing prerequisite in step 3
  • 26.03.2019 added a trouble shooting guide for analyzing connectivity issues


As of today (February 28th, 2019) it is possible to call remote enabled function modules in your on-premise systems from SAP Cloud Platform – ABAP environment.

How to integrate on-premise systems is described in the SAP online documentation.

Though the documentation is detailed I found, when setting up the scenario myself, that it might be helpful to have some screen shots from a working configuration.


Blog series

This blog is part of a blog series about developing a side-by-side Extension for on-premise SAP Systems in SAP Cloud Platform ABAP Environment using RFC communication

Step-by-Step description

Since meanwhile there is a nice tutorial available on that describes the basic setup very detailed step-by-step I have removed my step-by-step description and just provide pictures and screen shots to highlight the most important aspects of this setup.

Tutorial: Call a Remote Function Module From ABAP Environment


When calling an RFC function module in SAP Cloud Platform ABAP environment the RFC destination that you are using is created on the fly by calling the method


This method takes two parameters.

The first parameter i_name contains the name of the RFC system that is defined in the destination service instance in the space (here DEV) in your Cloud Foundry sub account.

The second parameter i_service_instance_name contains the Service Instance Name that is maintained in the Additional Properties of a Communication Arrangement that is based on the Scenario ID: SAP_COM_276.

DATA(lo_rfc_dest) = cl_rfc_destination_provider=>create_by_cloud_destination(
                    i_name = |S4H_RFC|
                    i_service_instance_name = |SAP_COM_0276_DevDays2019| ).


The complete overview of this scenario is depicted in the following picture.



Communication Arrangement (SAP Cloud Platform ABAP environment)

In the ABAP tenant we have created a communication arrangement that is based on the Scenario ID SAP_COM_276.

The value that is important when calling the RFC destination from your ABAP code is the Service Instance Name, that is maintained in the Additional Properties. In this case we chose the Service Instance Name SAP_COM_0276_DevDays2019.

RFC System (SAP Cloud Platform, Cloud Foundry)

The RFC System details have been maintained in an instance of the destination service of the space where your SAP Cloud Platform ABAP instance is running.

Please note that the hostname that is used (Parameter jco.client.ashost) is the virtual hostname (here: virtualhosts4h) that has been defined in the SAP Cloud Connector.

The name S4H_RFC of the RFC destination is the second parameter that is used in our ABAP code to generate an RFC destination on the fly.

SAP Cloud Connector (on premise)

In the SAP Cloud Connector we have configure a virtual host name (here: virtualhosts4h) that is different from the internal hostname (vhcals4hcs.dummy.nodomain) to shield the internal network details from the outside world.

Test the setup

Now you should be able to test the setup by creating a simple ABAP class, that uses the interface IF_OO_ADT_CLASSRUN and implements the method IF_OO_ADT_CLASSRUN~MAIN and that can be started by pressing F9.

This interface comes very handy since in SAP Cloud Platform ABAP Environment you cannot develop any classic reports. The interface allows you to display any kind of text and/or content of data into the Console View of the ADT Tools.

Please remember that the name of the RFC destination has to be determined by the method:


This method takes the name of your RFC destination (here: S4H_RFC) and the name of the destintation service (here: SAP_COM_0276_DevDays2019) as a parameter.

CLASS z_test_rfc_conn DEFINITION

    INTERFACES if_oo_adt_classrun.

  METHOD if_oo_adt_classrun~main.
        DATA(lo_rfc_dest) = cl_rfc_destination_provider=>create_by_cloud_destination(
                               i_name = |S4H_RFC|
                               i_service_instance_name = |SAP_COM_0276_DevDays2019| ).
        DATA(lv_rfc_dest) = lo_rfc_dest->get_destination_name( ).
        DATA msg TYPE c LENGTH 255.
        "RFC Call
        DATA lv_result TYPE c LENGTH 200.
            rfcsi_export          = lv_result
            system_failure        = 1 MESSAGE msg
            communication_failure = 2 MESSAGE msg
            OTHERS                = 3.

        CASE sy-subrc.
          WHEN 0.
            out->write( lv_result ).
          WHEN 1.
            out->write( |EXCEPTION SYSTEM_FAILURE | && msg ).
          WHEN 2.
            out->write( |EXCEPTION COMMUNICATION_FAILURE | && msg ).
          WHEN 3.
            out->write( |EXCEPTION OTHERS| ).

      CATCH cx_root INTO DATA(lx_root).
        out->write( lx_root->get_text( ) ).



The RFC function module returns a simple string that contains some information about the system being called.

(see also the screen shot of the console output above)

114103LITIE3vhcals4hci_S4H_00               vhcals4hS4H     S4H     vhcalhdbdb                      HDB       753   390Linux          0 x.x.x.x   773 vhcals4hci

Potential issues

When your on-premise system is not reachable because it is down or because you made an error when configuring the connectivity you will get appropriate error message.

Destination S4H_RFCa not found.

Troubleshooting the Cloud Connector

  • Audits in the Cloud Connector (after a simulated RFC call): empty
  • Trace in the Cloud Connector (after a simulated RFC call): empty
  • Function Module is listed as an accessible resource in Cloud Connector
  • Internal Host is reachable in Cloud Connector
  • Correct NEO Subaccount is configured in Cloud Connector
  • Destination Service Communciation Arrangement SAP_COM_0276 is configured
  • SAP_COM_0200 is configured

More information

In another blog I explain how you can generate appropriate DDIC structures to call your on premise RFC function modules since the SAP Cloud Platform ABAP environment is “empty” and does not contain structures needed to call RFC function modules from on premises SAP Business Suite or S/4HANA systems.

How to generate the DDL source code for custom entities that are implemented by remote function calls

and I will explain how a custom entity can be implemented in SAP CP ABAP Environment that reads product demo data from an on-premise system.

So stay tuned …


Assigned Tags

      You must be Logged on to comment or reply to a post.
      Author's profile photo Shani Niza
      Shani Niza

      Very useful Andre. Keep updating.

      Author's profile photo Gaurav Karkara
      Gaurav Karkara

      This helps. Thanks a lot.

      Author's profile photo Shani Niza
      Shani Niza

      Hi Andre,

      I have a doubt, I understand that in SAP CP ABAP environment we are use restful ABAP programming to create services.

      Can copy the onpremise FM logic and resuse it?

      I have done a whitelist check for cloud platform and FM comes in a forbidden object category.

      Could you please comment more in this?

      Author's profile photo Andre Fischer
      Andre Fischer
      Blog Post Author

      SAP CP ABAP environment can serve as a platform to built side-by-side extensions for:

      • SAP S/4HANA Cloud
      • SAP S/4HANA (on-Premises)
      • SAP Business Suite (on-Premises)

      The ABAP Restful Programming Model offers the option to built CDS as views that are annotated as "custom entities".

      Rather than querying the data from database tables or other CDS views the developer can retrieve the data via OData or RFC calls. In SAP CP ABAP Environment these are remote calls to one of the system types mentioned above.

      This function module is part of the SAP Basis and hence also available in SAP CP ABAP Environment locally but it is not released. I used it nevertheless as an example to show a simple RFC call.

      Later in upcoming versions of SAP S/4HANA you will be able to use this programming model als on-premises so that you are able to leverage legacy API's such as BAPI's.



      Author's profile photo Shani Niza
      Shani Niza

      Thanks Andre. So you will suggest not to use the FM. Actualy I was thinking to call FM in modify method lcl_handler of the behavior definition to to do some complex logics before updating the table . We need some data manipulations before updating the table in back end as we are trying to do one module pool application in on premise using UI5 and ABAP stack in cloud platform.

      Can we add some methods in class lcl_handler so that we can copy the logic from onpremise to cloud in that method rather than creating Fms and calling them.


      Author's profile photo chen yu
      chen yu

      Hello Andre,

      When i try to complet step 5 'Create a new RFC destination for the destination service instance', I can't connect to my abap system. I don't know where to fix it? Maybe my system version is not 1809..

      Author's profile photo Andre Fischer
      Andre Fischer
      Blog Post Author

      Please post your question her: Ask a Question and use the tag "SAP Cloud Platform, ABAP environment".

      There I would like to ask you to add more details what does not work in detail.

      Author's profile photo Pradeep Tripathi
      Pradeep Tripathi

      Hi Andre I just want to know can we create custom function module in abap environment on SAP cloud platform? or this this concept is deprecated there

      Author's profile photo Andre Fischer
      Andre Fischer
      Blog Post Author

      Custom function modules are supported. You check out yourself in the free trial version:

      But for business logic running locally in the ABAP cloud system you would probably rather using classes.

      Author's profile photo Anup Nair
      Anup Nair

      Thanks for sharing Andre!

      Author's profile photo Amrita Laxmi
      Amrita Laxmi

      Hi Andre,


      How can i connect to a RFC WebSocket using Cloud connector?

      Author's profile photo Markus Tolksdorf
      Markus Tolksdorf

      Hello Amrita,

      For Cloud Connector this is not possible, Cloud Connector connects to an ABAP system using CPIC only. Is there a reason why you'd connect from Cloud Connector to an ABAP system using WebSocket RFC?

      Best regards,

      Author's profile photo Arnold Mirashi
      Arnold Mirashi

      Hi Andre ,

      I am trying to make the code functional and now I am having the SY-SUBRC = 2 after the call of the function module  :

                  rfcsi_export          = lv_result
                  system_failure        = 1 MESSAGE msg
                  communication_failure = 2 MESSAGE msg
                  OTHERS                = 3.

      with the message :

      • EXCEPTION COMMUNICATION_FAILURE - Error when opening an RFC connection (Cannot open tunnel with id account:///).

      Could you please guide me to fix this error ?


      Thank you !


      Author's profile photo Gregor Wolf
      Gregor Wolf

      Hi Andre,

      when looking at the provided documenation link: Create a Communication Arrangement for Cloud Connector Integration (Deprecated) seems that RFC Communication via Communication Arrangements is the way to go. It seems that the Tutorial: Call a Remote Function Module From SAP Business Technology Platform (BTP), ABAP Environment provides the most up-to-date information. I would suggest you mention that on the top of your post.

      Best Regards

      Author's profile photo Sri Jayant
      Sri Jayant

      Hi Andre,

      I am trying to do the other way arround, i couldnt find anything on this,

      is this possibe same way ?

      any Resources ?


      Regards, SriJayant

      Author's profile photo Andre Fischer
      Andre Fischer
      Blog Post Author

      You have to create a communication arrangement in the Steampunk system.

      RFC Communication via Communication Arrangements | SAP Help Portal