Use SAP Cloud Connector + SAP Cloud Platform + Java to consume function in ABAP On-Premise system
Recently I was assigned to a prototype development which needs to consume some function modules in ABAP On-Premise system.The scenario is something similar as the one introduced in my blog C4C Wechat development series except some difference:
SAP Cloud for Customer is a cloud solution whose OData service / Web Service could directly be consumed by other application in the Internet. And the prototype I am working on recently needs to consume function modules in ABAP On-Premise system hosted in Corporate Network, which is not directly available for Internet application.
To bridge this gap, SAP Cloud Connector is used.
In this blog I implement a simple scenario to demonstrate how Cloud Connector works: develop a Java Web application which consumes function module in ABAP On-Premise system, and deploy it onto SAP Cloud Platform. I can access this Java application via Wechat application in my mobile phone, and then function module in ABAP system is called.
Major implementation steps:
1. Download and configure Cloud Connector, which should be deployed in Corporate Network as well.
2. Finish configuration in SAP Cloud Platform to establish the connection between SAP Cloud Platform and SAP Cloud Connector.
3. Develop Java Web application and deploy onto SAP Cloud Platform.
Architecture as below:
Implementation details are listed below.
1. Cloud Connector installation and setup
Download from this url.
Once installation is done, launch and ensure it appears in the service list of your OS:
Cloud Connector Log on page:
Create a new Connector instance, I name it as Jerry_SCC. The Region and Subaccount should be maintained using the corresponding fields of the SAP Cloud Platform to be connected.
A created Connector instance looks like below. Click tab “Cloud To On-Premise”:
In this UI a mapping relationship is maintained to link a virtual system to ABAP On-Premise system. The virtual system created by me is named as my-backend-system, which points to an internal ABAP system AG3. Specify Protocol as RFC. If everything is correctly maintained, press check button and the status of ABAP system would be marked as Reachable.
Maintain Function Name as STFC, and Naming Policy as Prefix. It means function modules in AG3 with prefix STFC are available for this Connector instance.
2. Configuration in SAP Cloud Platform
Now the created Cloud Connector instance is visible in SAP Cloud Platform.
In this step, a destination is created in SCP which will be consumed by my Java application. This destination behaves as the ABAP destination created via tcode SM59.
The destination setting could be found below. I name it as my-backend-system-destination, here the user and password in ABAP On-Premise system is filled.
Press button “Check Connection” to ensure the destination works as expected.
3. Create Java Web application to consume destination created in step 2
The whole source code of this Web application could be found from my github.
Deploy it to SCP.
Brief introduction of core code:
(1) in line 28, get Destination instance by name. The name is specified in step 2.
(2) in line 31, get handle of ABAP function module STFC_CONNECTION.
(3) in line 35, get user input passed via url.
(4) in line 38, fill the user input to importing parameter REQUTEXT of function module STFC_CONNECTION.
(5) in line 42, execute function module.
(6) in line 45, 46, get execution result.
Test in Wechat:
Also set a breakpoint in STFC_CONNECTION to double confirm that it is really called by my Wechat access in mobile phone via RFC: