Throughout this tutorial, replace XXX
or JP
with your initials or group number.
The problem:
There are two problems when setting up connectivity between the Cloud Platform ABAP Environment and an on-premise:
- The ABAP Environment “lives” in the Internet, but customer on-premise systems are behind a firewall
- RFC is not internet-enabled
The solution:
- Set up a connection from the on-premise system to the SAP Cloud Platform Neo Environment using SAP Cloud Connector
- Set up a connection from the SAP Neo to the SAP Cloud Foundry Environment
Specifically:
- The ABAP environment tenant fetches the destination from the Destination service instance.
- The ABAP environment tenant requests to open the tunnel connection through the Connectivity service.
- The Connectivity service tells the Cloud Connector to open the connection to this specific ABAP environment tenant using the admin connection.
- The Cloud Connector opens a tunnel connection to the ABAP environment tenant using its public tenant URL.
- After the tunnel is established, it can be used for actual data connection using the RFC or HTTP(S) protocols.
Step 1: Configure SAP Cloud Connector
First, you need to connect your ABAP on-premise system to a Cloud Foundry subaccount by means of SAP Cloud Connector.
-
In your browser, log on to SAP Cloud Connector:
- Address = e.g.
https://localhost:<port>
(Default = 8443)
- User = Administrator
- Initial password = Manage (You will change this when you first log in)
-
Choose Add Subaccount:
Field Name |
Value |
Region |
Your region. You can find this in SAP Cloud Cockpit (see screenshot below) - e.g. here, Europe (Frankfurt) - AWS |
Subaccount |
Cloud Foundry Subaccount ID. You can find this by choosing your subaccount in SAP Cloud Cockpit and choosing the information (i) icon. (see screenshot below) |
Display Name |
(Subaccount) Display Name. You can find this in by choosing your subaccount in SAP Cloud Cockpit (see screenshot below) |
Subaccount User |
Password |
Location ID |
Optional here. However, it is mandatory if you want to connect several Cloud Connectors to your subaccount. This can be any text, e.g. XXX for your initials or group number as here |
Your configuration should now look like this. Note down the Location ID, here XXX
. You will need it later.


Step 2: Add On-Premise System
-
In the menu in the left pane, expand the subaccount and choose Cloud To On-Premise > Access Control.
-
In the Mapping Virtual to Internal System pane, choose Add (+).
-
Enter the following values, and choose Save.
Field Name |
Value |
Backend Type |
ABAP |
Protocol |
RFC |
|
Without Load Balancing |
Application Server |
IP address of the on-premise server, e.g. of NPL |
Instance Number |
00 |
Virtual Host |
e.g. nplhost . This represents an external hostname, so that you can hide the internal hostname from the outside world. You will need this external hostname and port later, when creating a destination from SAP Cloud Cockpit. |
Virt. Inst. No. |
00 |
Principal Type |
None |
Description |
Optional |
Check Internal Host |
Ticked |
The mapping should now look something like this. Check that the status = Reachable
. If not, check that you chose the correct port, or whether an internal firewall is preventing communication:
Step 3: Specify remote function modules and BAPIs
Now, still in the Cloud to On-Premise > Access Control tab, enter the resource you need, RFC_SYSTEM_INFO
.
-
Add the resource RFC_SYSTEM_INFO
by choosing the Protocol = RFC, then choosing +.
-
Enter the name of the RFC, e.g. RFC_SYSTEM_INFO
. Alternatively, add RFC
as a Prefix. Then choose Save
-
Add BAPIs to the list of resources by choosing + again. (You will need this BAPI in a later tutorial.)
-
Enter the name BAPI_EPM
as a Prefix, then choose Save.
-
The list of resources should now look roughly like this.
Step 4: Check connectivity from SAP Cloud Cockpit
In the SAP Cloud Platform Cockpit of your Cloud Foundry subaccount, choose Cloud Connectors:
The location ID points to the correct SAP Cloud Connector (located in the on-Premise system); The virtual host points to the on-Premise connection mapped in SAP Cloud Connector.
Step 5: Create destination
You will now create a destination in the ABAP Environment. This must be created at subaccount (not Space) level.
-
In the SAP Cloud Platform Cockpit of your Cloud Foundry subaccount, choose Destinations, then choose New Destinations.
-
Enter the following values:
Field Name |
Value |
Name |
e.g. NPL_JP as here |
Type |
RFC |
Description |
Can be anything, here NPL |
Location ID |
same as in step 1, e.g. XXX |
User |
Your user for the on-premise system, e.g. DEVELOPER |
Password |
Your password |
-
Add the following additional properties and values, by choosing New Property:
Field Name |
Value |
jco.client.ashost |
Virtual hostname of your on-premise ABAP System, defined in SAP Cloud Connector, e.g. <nplhost> |
jco.client.client |
<Your ABAP System client , e.g. 001 |
jco.client.sysnr |
<Your ABAP System number> , e.g. 00 |
.

Step 6: Create ABAP class for RFC connection
-
Create a new ABAP class: Choose File > New > Other… > ABAP Class.
-
Enter a name and description. The name should be in the form ZCL_...RFC_XXX
. Replace XXX
with your group number or initials.
-
Create or assign a transport request.
Step 7: Add interfaces statement; implement main method
-
Implement the interface by adding this statement to the public section:
interfaces if_oo_adt_classrun.
This allows you to test your class by displaying the output in the ABAP Console.
-
In the implementation section, add the METHOD and ENDMETHOD statements:
METHOD IF_OO_ADT_CLASSRUN~MAIN.
ENDMETHOD.
Step 8: Create variables
Create the data types that specify your remote connection information, replacing the i_name
with your the name of the specific RFC destination, which you created in SAP Cloud Cockpit (in step 5 of this tutorial).
```ABAP
DATA(lo_destination) = cl_rfc_destination_provider=>CREATE_BY_CLOUD_DESTINATION(
i_name = 'NPL_JP'
).
DATA(lv_destination) = lo_destination->get_destination_name( ).
DATA lv_result type c length 200.
```
Step 9: Call remote function from on-premise system
CALL function 'RFC_SYSTEM_INFO'
destination lv_destination
IMPORTING
RFCSI_EXPORT = lv_result.
Step 10: Output result
Output the result of the RFC call to the ABAP Console
out->write( lv_result ).
Step 11: Wrap method in an exception
Wrap the whole method in an exception using TRY…CATCH.
catch cx_root into data(lx_root).
out->write( lx_root->get_text( ) ).
endtry.
Step 12: Check your code
Your code should look roughly like this:
CLASS ZCL_A4C_RFC_XXX DEFINITION
public
final
create public .
public section.
interfaces if_oo_adt_classrun.
protected section.
private section.
ENDCLASS.
CLASS ZCL_A4C_RFC_XXX IMPLEMENTATION.
METHOD IF_OO_ADT_CLASSRUN~MAIN.
TRY.
DATA(lo_destination) = cl_rfc_destination_provider=>CREATE_BY_CLOUD_DESTINATION(
i_name = 'NPL_JP'
).
DATA(lv_destination) = lo_destination->get_destination_name( ).
DATA lv_result type c length 200.
CALL function 'RFC_SYSTEM_INFO'
destination lv_destination
IMPORTING
RFCSI_EXPORT = lv_result.
out->write( lv_result ).
catch cx_root into data(lx_root).
out->write( lx_root->get_text( ) ).
endtry.
ENDMETHOD.
ENDCLASS.
Step 13: Test the class
-
Save and activate the class, using Ctrl+S, Ctrl+F3
.
-
Run the class by choosing F9
. Some system information, such as the hostname, the System ID ( <SID>
), and the IP address should be displayed.
Step 15: Add error handling to the class for the RFC connection
-
Go back to your RFC class. Remove the period (.) after the IMPORTING parameter and add the following exception parameters to the function call RFC_SYSTEM_INFO
:
EXCEPTIONS
system_failure = 1 MESSAGE msg
communication_failure = 2 MESSAGE msg
OTHERS = 3.
-
Now evaluate sy-subrc
by adding the following CASE…ENDCASE statement:
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.
More Information
For more information on SAP Cloud Platform:
- SAP Help Portal: What is SAP Cloud Platform
For more information on connectivity in this context, see:
- SAP Help Portal: SAP Cloud Connector
For more information on OData services and SAP Gateway in general, see: