Technical Articles
S/4HANA Extensibility: How to Connect Your SAP S/4HANA Cloud to SAP Cloud Platform (SAP CP)
In this article I want to show you how to connect you SAP S/4HANA Cloud system to SAP Cloud Platform (SAP CP) to build extension apps.
SAP S/4HANA Cloud provides predefined SAP services (for example various services from the Cloud Marketing Edition and services from the Enterprise Edition such as Project Maintenance). As of 1608 you can also define custom services that you can use on SAP CP.
Before you go into the details, you should consider:
- You need a valid SAP CP account. You can connect multiple SAP CP account to an SAP S/4HANA Cloud system and vice versa. In other words, SAP CP account and SAP S/4HANA Cloud system can be connected with a cardinality of n:m.
- You need no cloud connector for the connection from SAP S/4HANA Cloud system to SAP CP .
- For an S/4HANA Cloud (on premise) system or SAP Business Suite system this has been described in many articles (see for example: https://blogs.sap.com/2016/02/01/unlock-the-business-suite-with-sap-hana-cloud-platform-sap-teched-lecture-of-the-week/ and in the documentation on SAP Cloud Connector
The remainder of this article consists of three parts (plus prerequisites):
- The setup of the connection between your SAP S/4HANA Cloud account and your SAP CP account (one-time activity per SAP S/4HANA Cloud account and SAP CP account)
- The configuration of a new service that shall be used in your SAP CP account (activity per service)
- One example how to consume the exposed service on SAP CP (with SAP Web IDE).
0. Prerequisites
- SAP S/4HANA Cloud: In the Maintain Business User Fiori app, assign a business role with the business catalog Communication Management and Extensibility to the user that is going to do the setup. As a result, the user will see the following Fiori apps
- Maintain Communication Users
- Communication Systems
- Communication Arrangements
- Custom Communication Scenarios
- SAP CP : You have administration access the SAP CP account
1. Setup of the SAP S/4HANA Cloud – SAP CP Connection
The setup consists of two parts
- SAP S/4HANA Cloud: creation of the communication system and user
- SAP CP : creation of the destination
To create the communication system and communication user in SAP S/4HANA Cloud:
- Open the Fiori app Communication Systems, create a new communication system (you can name it for example SCP).
- In section User for Inbound Communication, create a new communication user (you can name it for example SCP). Enter a password or let the system create one. You can also use a certificate.
- All remaining fields, such as Contact person, E-Mail, Phone, etc. are optional.
- Save the new communication system, and check that the status says Active.
For additional documentation on the named Fiori apps, see the official user documentation: https://cp.hana.ondemand.com/dps/d/preview/1a93686c176845f0832a2a73221dd90b/1608%20500/en-US/frameset.htm?95d496fad8bc4a5ebf6b6a77a9eb616d.html
To create of the destination in SAP CP :
- Open your SAP CP account, go to Connectivity, Destinations
- Create a new destination with the following attributes:
- Name: choose a name for example “S4HANA”
- Type: HTTP (this includes HTTPS, which is used)
- Description: choose a description for example “S4HANA”
- URL: enter the URL of you S/4HANA account, for example “https://myserver.s4hana.ondemand.com”
- Proxy Type: Internet
- Authentication: BasicAuthentication
- User & Password: enter the user / pwd you created before, for example “SCP”
- Check “Use default JDK truststore” for security settings
- Only if you want to use Web IDE (see section 3, below), set the Additional Properties:
- WebIDEEnabled: true
- WebIDESystem: name of the system, e.g. “S4HANA”
- WebIDEUsage: odata_gen
Screenshot: SAP CP Cockpit: Destination Configuration
For additional documentation on SAP CP destinations, see the official user documentation: https://help.hana.ondemand.com/help/frameset.htm?1e110da0ddd8453aaf5aed2485d84f25.html
Result: Your SAP S/4HANA Cloud account and your SAP CP account are now connected.
2. Expose a SAP S/4HANA Cloud Service So That It Can Be Used in SAP CP
Before we describe how to configure a SAP S/4HANA Cloud service for SAP CP , I would like to give an overview which services can be configured for SAP CP :
- Predefined SAP services: for example various services from the Cloud Marketing Edition and services from the Enterprise Edition such as Project Maintenance.
- Custom services: as of version 1608 you can expose Custom Business Objects as service on SAP CP . As of version 1702 you can expose Custom CDS Views as external services. For details see: https://blogs.sap.com/2015/09/30/the-key-user-extensibility-tools-of-s4-hana/
To find the predefined SAP services, you can check the SAP API Business Hub https://api.sap.com/, select SAP S/4HANA Marketing Cloud or SAP S/4HANA Cloud. (Note: As far as I can see, not all available services are registered there yet. You can see all services in the system in the Communication Arrangement app, see below.)
Screenshot: SAP API Business Hub showing the details of a S/4HANA cloud service
To expose a predefined SAP S/4HANA Cloud service to be used in SAP CP :
- Open the Fiori app Communication Arrangement, create a new communication arrangement.
- Select an SAP communication scenario from the list. A communication scenario represents one or more predefined SAP services. For example, you could select “SAP_COM_0004: Marketing – Business Data Integration”. As mentioned, in the list you may find more services than already documented in the SAP API Hub.
- Select the communication system that you created in the setup step, for example “SCP”.
- Save the new communication system, and check that the status says Active.
As an example, see the following screenshot.
Screenshot: Communication Arrangement Fiori app
Result: The selected services are now available in SAP CP under destination you created before (for example “S4HANA”). In the communication scenario screen, you can find the service URL that you can use in SAP CP to access the service.
To configure a custom service to be used in SAP CP :
- Open the Fiori app Custom Communication Scenarios, create a new Communication Scenario.
- Enter a name and description, for example the name of the custom service.
- Click the “Add” button. In the selection list, all custom business objects are shown. Select a custom business object that you want to expose as external service. In the future, also custom CDS views and custom analytical queries will be available here.
- Save and publish the new communication scenario, and check that the status says Published.
- Continue with the procedure as described for predefined SAP S/4HANA Cloud service.
For additional documentation on the named Fiori apps, see the official user documentation: https://cp.hana.ondemand.com/dps/d/preview/1a93686c176845f0832a2a73221dd90b/1608%20500/en-US/frameset.htm?95d496fad8bc4a5ebf6b6a77a9eb616d.html
Result: The selected service is now available in SAP CP under the destination you created before (for example “S4HANA”).
What happens “under the hood”? By creating a communication scenario, you assign an authorization role to the communication user of the related communication system. For a SAP-defined communication scenario, the role already exists in the system. For a custom service, the authorization role is created when publishing the custom communication scenario.
3. Use the Service in SAP CP
You can use a service in SAP CP in many different way. You can use it to build a new UI, you can call it in your Java or JavaScript coding, you can use it in HANA Cloud Integration iFlows. Here I want to show only one simple use case on how to consume it: SAP Web IDE.
- Start SAP Web IDE. (From you SAP CP account dashboard, select Services, search for SAP Web IDE, click Open SAP Web IDE.)
- Select: File, New, New Project from Template.
- Select for example SAP Fiori Master Detail Application.
- Enter a name for a project
- On the step Data Connection, select Service URL. Select the destination you created before and the relative path of the OData service, as given in the Communication Arrangement screen. You can now discover the details of the service and you can even discover the live data (see the screenshot below)
- Continue with the creation wizard to create a Fiori app out of the OData service.
Screenshot: Consuming the exposed service in SAP Web IDE
Result: The exposed service is used in a Fiori app running on SAP CP .
Hi Thomas,
I followed your guide but am getting a "500 Internal Server Error" in the WebIDE. Is there some way I can debug/work out what is going wrong?
Thanks
Simon
Hi Simon,
sorry for the late response. I assume that the S/4HANA is a Cloud system. in this case, you have no debugging option. Have you tested the URL that is provided in the Communication Arrangment Fiori app (see screenshot in my post) directly in a browser? If you also get an error in the browser, the error is on the S/4HANA side. If it is okay in the browser, then the configuration on the HCP side is errorous. On the other hand: the name of the OData service looks strange. The "CPD" part of the name looks strange.
Hi Thomas,
I have gone through several of your blogs . I would like to know the possibility of replicating master data ( full load or delta load ) from S/4Hana Cloud to SCP . What approach shall we follow for the same ?
Excellent! Easy does it.
Hello Thomas,
I am trying to deploy a java application that connects to an SAP Marketing Cloud system, are there any examples on how to use the HCP destinations in a java application?
Thanks,
Mourad
Hi Mourad,
I have some links that may be helpful:
https://help.sap.com/viewer/cca91383641e40ffbe03bdc78f00f681/Cloud/en-US/462dbffef4614044b5c727c9de37672e.html
https://blogs.sap.com/2017/05/10/first-steps-with-sap-s4hana-cloud-sdk/
Best regards,
Thomas
.
we've performed all steps
2. destination in SCP ( connection to s/4 hana public cloud is successful )
now we are trying to create app from WEB-IDE by using your step 3. while doing this we are getting an error saying "Unable to reach the catalog service, Please check service configuration.
Thomas,
This is really nice blog, we have developed an app connecting to S/4 hana cloud test system, working just fine, we would like to move this production, can you help us on how to do that?
Hi,
this is unfortunately beyond the scope of this blog. SAP CP has means of transporting apps from the Q to P (sub) account. This is independently of the S/4HANA Cloud system.
Best regards,
Thomas
.
Hi Thomas,
I have this error “403 Forbidden” in the WebIDE. do you have any idea how to solve this issue?
Hi Thomas,
This blog is written in 2016.
Is this still valid for the newest version of SCP and S/4 Cloud?
Thank you.
Hi Thomas,
Thanks for such nice blog, it is well written , and very helpful even today 2019. I need a clarification / help related to the last one : "You can use a service in SAP CP in many different way. You can use it to build a new UI, you can call it in your Java or JavaScript coding, you can use it in HANA Cloud Integration iFlows. Here I want to show only one simple use case on how to consume it: SAP Web IDE."
Questiton:
I would like to know do you have any blog or samples that will explain " consuming a custom business object exposed odata service in SAP CP , via Java coding ?"
As far as i know, everywhere the VDM way of coding for existing Services that are exposed in SAP API business hub. But none explained more on those services exposed only via custom business object. or it is explained only for Web IDE. My question above is purely a) consuming in a pure java application in sap cp b) only custom business object in s4hana cloud exposed odata service.
THanks
Sampath Ramanujam
Hi,
I do not know about a blog that explains this in detail.
If you are using the SAP Cloud SDK (fka SAP S/4HANA Cloud Extension SDK) you can generate a Java "stub" for the CBO.
If you are not using the SAP Cloud SDK, you can consume it like any other OData service.
Best regards, Thomas
Hello Thomas,
Thanks for the detailed explanation.
Can we connect cloud system to SCP trial account as well?
Thanks,
Mukesh