In the previous blog post of this series we called a BAPI in the Cloud using a Java Program and the SAP Java Connector Librarier. In this Blog Post I will describe how to make an RFC call from SAP Cloud Platform Integration to an SAP On-Premise System. It also gave me the idea for the test case in the final Blog Post of this series.
Calling a BAPI in an SAP On-premise system from the Cloud
The principle set-up is depicted below.
What I used
- A functional SAP Cloud Connector Instance + user with administrative privileges
- An SAP Cloud Platform Integration tenant + user with administrative privileges
- Postman on my Desktop
What I did
- Set up Service Channel towards the OnPrem System
- Maintain a Destination in the Cloud Cockpit Subaccount
- Set up a simple IFlow in SAP Cloud Platform Integration using the RFC Adapter
- Test the connection and the BAPI from Postman
Setting up the IFlow
The IFlow is simple and looks like this:
The Groovy Scripts are just payload loggers. The interesting part is the RFC-Call. The RFC destination needs to be maintained in the SAP Cloud Platform Destinations of the subaccount the SAP Cloud Platform Integration belongs to. But first the SAP Cloud Connector-Channel to the SAP On-Premise System needs to be set up. With the result of that we can easily maintain the destination in the SAP Cloud Platform Cockpit.
In SCC go to “Cloud to On-Premise” and create a new channel by pressing the “+” on the top-right of the screen. Create a new RFC-channel. Take care about the Virtual Host Name because you can’t change it later on. You will use that name in the destination in SCP later.
Put the data of your backend system here:
You can’t change the Virtual Application Server Name later so take care and avoid special characters!
When you maintained everything correctly, your new virtual server will appear as “Reachable”. Now you need to add a resource. For that, highlight your server and add a resource:
Go to the Cloud Cockpit and subaccount of the CPI. If you look into the attached Cloud Connectors, you can find our newly created destination:
Now go to destinations and create a new one:
Add the additional properties for your target. As “ashost” you set the name you maintained in the SAP Cloud Connector. The name of the destination (“OnPremRFCTarget”) will be used later in the SAP Cloud Platform Integration Flow.
Check the connection. If you get the message below, then the name for jco.client.ashost is not correct:
Now go into the SAP Cloud Platform Integration and maintain the Iflow. To send the data you need to maintain the RFC Receiver Adapter:
The setting “Send confirm transaction” is only needed when you want to persist data in the target (“BAPI_COMMIT”). Save and Deploy the Integration Flow.
From Postman you can call the IFlow with this sample payload (change the MateriaI-Number accordingly):
<?xml version="1.0" encoding="UTF-8"?> <ns1:BAPI_MATERIAL_GET_DETAIL xmlns:ns1="urn:sap-com:document:sap:rfc:functions"> <MATERIAL>000000000000000018</MATERIAL> </ns1:BAPI_MATERIAL_GET_DETAIL>
Make it a POST request via https with basic authentication (with an appropriate user on SAP Cloud Platform Integration).
As an answer we get the material in a ll its beauty:
<?xml version="1.0" encoding="UTF-8" standalone="no"?> <rfc:BAPI_MATERIAL_GET_DETAIL.Response xmlns:rfc="urn:sap-com:document:sap:rfc:functions"><MATERIALPLANTDATA> <PUR_GROUP/> <ISSUE_UNIT/> </MATERIALPLANTDATA> <MATERIALVALUATIONDATA> <PRICE_CTRL/> <MOVING_PR>0.0000</MOVING_PR> <STD_PRICE>0.0000</STD_PRICE> <PRICE_UNIT>0</PRICE_UNIT> <CURRENCY/> <CURRENCY_ISO/> </MATERIALVALUATIONDATA> <MATERIAL_GENERAL_DATA> <MATL_DESC>ROTOR,AIRCRAFT GAS TURBINE</MATL_DESC> <OLD_MAT_NO>3842133-1</OLD_MAT_NO> <MATL_TYPE>ZNIN</MATL_TYPE> <IND_SECTOR>M</IND_SECTOR> <DIVISION>01</DIVISION> <MATL_GROUP>01</MATL_GROUP> <PROD_HIER/> <BASIC_MATL>2835</BASIC_MATL> <STD_DESCR/> <LAB_DESIGN>001</LAB_DESIGN> <PROD_MEMO/> <PAGEFORMAT/> <CONTAINER/> <STOR_CONDS/> <TEMP_CONDS/> <BASE_UOM>EA</BASE_UOM> <EAN_UPC/> <EAN_CAT/> <SIZE_DIM>007.0X007.0X004.4 INCHES</SIZE_DIM> <GROSS_WT>8.000</GROSS_WT> <NET_WEIGHT>7.000</NET_WEIGHT> <UNIT_OF_WT>LB</UNIT_OF_WT> <VOLUME>0.222</VOLUME> <VOLUMEUNIT>FT3</VOLUMEUNIT> <LENGTH>0.000</LENGTH> <WIDTH>0.000</WIDTH> <HEIGHT>0.000</HEIGHT> <UNIT_DIM/><MANU_MAT/> <MFR_NO/> <BASE_UOM_ISO>EA</BASE_UOM_ISO> <UNIT_OF_WT_ISO>LB</UNIT_OF_WT_ISO> <VOLUMEUNIT_ISO>FT3</VOLUMEUNIT_ISO> <UNIT_DIM_ISO/> <CREATED_ON>2018-01-16</CREATED_ON> <CREATED_BY>I802623</CREATED_BY> <LAST_CHNGE>2018-01-18</LAST_CHNGE> <CHANGED_BY>I802623</CHANGED_BY> <MATL_CAT/> <EMPTIESBOM/> <BASIC_MATL_NEW>2835</BASIC_MATL_NEW> </MATERIAL_GENERAL_DATA> <RETURN> <TYPE>S</TYPE><CODE/> <MESSAGE/> <LOG_NO/> <LOG_MSG_NO>000000</LOG_MSG_NO> <MESSAGE_V1/> <MESSAGE_V2/> <MESSAGE_V3/> <MESSAGE_V4/> </RETURN> </rfc:BAPI_MATERIAL_GET_DETAIL.Response>
Since this call goes toward an SAP On-Premise System, no restrictions which BAPIs can be used do apply.
What I learned from this test case
The interesting part was setting up the destination to be used in the Integration Flow. There is no drop-down list for available destinations so you need to know the name and, in my case, spell it properly. I was frustrated because the scenario wouldn’t work at first but after a while I found the typo and then it was ok.
The format of the xml sending into the SAP On-Premise system matches the definition of the related function module. You can look it up in transaction SE37.
So with the experience from the previous tests it was straightforward to set this up.
Please let me know if the description was helpful and you were able to set up the same test case. Any feedback how to improve this blog post is welcomed! Please put it in the comment section.
In the final Blog I will show you how I achieved to make an RFC Call from SAP Cloud Platform via the SAP Cloud Connector into the SAP S/4HANA Public Cloud. It will appear soon!