Quickly integrate SAP Analytics Cloud with other s...
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.
In your customer projects, you may have the need to integrate SAP Analytics Cloud with other systems, SAP or non-SAP systems, in order to pull data from them into SAP Analytics Cloud or send a write action to these external systems.
You can do it with Post Message API and OData connection. In this blog post, I would like to introduce another way, which I think might be more generic, user friendly and reusable – using the custom widgets in SAP Analytics Cloud, analytics designer.
I would like to share with you a demo, code example, and some frequently asked questions.
Demo
Let’s first look at a demo about how to get public data using public data API and how to create a purchase order item in S/4HANA Cloud using SAP API Business Hub.
cd c:\web (this is important as the relative path is now hard-coded in index.json)
lite-server
Congratulation!Now you can open SAP Analytics Cloud to create an Analytic Application, and you can directly add your own custom widget, the same as in my demo.
Connect to S/4HANA Cloud via SAP API Business Hub
The second custom widget connects to S/4HANA Cloud via SAP API Business Hub to create a purchase item.
As S/4HANA Cloud requires handling of CORS and authentication, we need a backend server like Node.js to do the communications. The S/4HANA Cloud example consists of two parts:
The custom widget: provides widget UI for SAP Analytics Cloud application developer
The Node.js: does CORS, authentication, and talks to S/4HANA Cloud
Try it by yourself
Setup communication scenario in S/4HANA Cloud. We need the username and password configured here in subsequent API calls.
Create the custom widget. It delegates the call to Node.js
Create the Node.js. As the code snippet is long, I only copy part of them here. For S/4Hana Cloud integration, please make sure you don’t miss first fetching “'x-csrf-token” then use this token in the subsequent calls by adding { 'x-csrf-token': 'fetch' } to the header.
Upload the custom widget's json file to SAP Analytics Cloud.
Start the web server and Node.js
Go to SAP Analytics Cloud to create an analytic application. Add your own custom widget, and send request to S/4HANA Cloud like I did in my demo recording.
Frequently asked questions
What are the user scenarios of using custom widgets to extend SAP Analytics Cloud’s integration capability?
Using custom widgets to extend SAP Analytics Cloud’s integration capability, you will have the possibility for many closed-loop scenarios like:
Pull data from external systems to SAP Analytics Cloud
Write data back to external systems
Trigger actions from SAP Analytics Cloud such as approve, create, update, delete, etc.
Send notification from SAP Analytics Cloud to external systems
Does it support non-SAP systems?
Yes. It is based on HTTP request. Any open system that accepts HTTP request can be integrated with SAP Analytics Cloud using this solution. For instance, if you have exposed REST API for customer’s OA and BPM systems, then these systems will be able to integrate with SAP Analytics Cloud.
What kinds of HTTP requests are supported?
No restrictions are set. The common get, post, patch are all supported.
What’s SAP API Business Hub?
SAP API Business Hub provides a standard way to easily build Apps, Integrations and Extensions based on SAP products. Supported products include SAP S/4HANA Cloud, SAP S/4HANA, SAP SuccessFactors, SAP Fieldglass, SAP Concur, SAP Ariba, SAP Cloud Platform, etc. More details: https://api.sap.com/
Yes, the Same-origin policy applies in this case as well.
Some public data sources, like the data source in our example, in its response, the server sends back header with Access-Control-Allow-Origin: *, which means that the resource can be accessed by any origin. Nothing special we need to handle in this case.
In most business systems, this needs to be addressed. Many third-party packages are available, for instance, CORS Node.js package. https://www.npmjs.com/package/cors
Any recommended API testing tool?
The Postman is an excellent one. It is better to run the API successfully in Postman, then wrap it as a custom widget. https://www.postman.com
Can I schedule the application to run repeatedly? For instance, I would like SAP Analytics Cloud to monitor the data, then based on my configuration, triggering the status update to external systems?
Yes. You can schedule the application to run at the backend with the scheduling feature in SAP Analytics Cloud.
Summary
By following this integration example, I hope you can quickly build up the closed-loop scenarios.