Technology Blogs by SAP
Learn how to extend and personalize SAP applications. Follow the SAP technology blog for insights into SAP BTP, ABAP, SAP Analytics Cloud, SAP HANA, and more.
cancel
Showing results for 
Search instead for 
Did you mean: 
Andre_Fischer
Product and Topic Expert
Product and Topic Expert

Updates



  • 26.03.2019 added the missing prerequisite in step 3

  • 26.03.2019 added a trouble shooting guide for analyzing connectivity issues


Introduction


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 http://developers.sap.com 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

Overview


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

cl_rfc_destination_provider=>create_by_cloud_destination

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:
cl_rfc_destination_provider=>create_by_cloud_destination

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
PUBLIC
FINAL
CREATE PUBLIC .

PUBLIC SECTION.
INTERFACES if_oo_adt_classrun.
PROTECTED SECTION.
PRIVATE SECTION.
ENDCLASS.



CLASS z_test_rfc_conn IMPLEMENTATION.
METHOD if_oo_adt_classrun~main.
TRY.
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.
CALL FUNCTION 'RFC_SYSTEM_INFO' DESTINATION lv_rfc_dest
IMPORTING
rfcsi_export = lv_result
EXCEPTIONS
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| ).
ENDCASE.

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

 

Result


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 call...

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 …

 
16 Comments