When working with SAP Datasphere, triggering task chains is often a crucial part of automating data processes. SAP Datasphere provides the ability to start task chains using CLI (Command Line Interface) commands, which offer a powerful way to control these operations. However, one challenge we faced was that SAP Analytics Cloud (SAC) doesn’t natively support calling CLI commands directly.
To overcome this limitation, we developed a custom solution: a FastAPI wrapper for the CLI commands, hosted on SAP Business Technology Platform (BTP). This API allows us to trigger SAP Datasphere task chains from SAC using a simple REST call. By utilizing SAC’s Multi Actions, we can now automate task chain execution seamlessly without leaving the SAC environment.
The following diagram illustrates the solution:
This integration provides a seamless way to automate processes between SAC and SAP Datasphere, unlocking powerful automation capabilities within a familiar interface. In this blog, we’ll walk through the steps to implement this solution and highlight the benefits it brings to your data workflows.
As a first step we created an OAuth client in SAP Datasphere.
And we also installed the datasphere CLI on our local machine.
Hint: For the CLI there exist already some great blogs and documentation:
Based on the following SAP Note https://me.sap.com/notes/3461484 we executed the login:
datasphere config cache init --host https://<tenantname>.hanacloudservices.cloud.sap/ --authorization-url https://<tenant name>.authentication.sap.hana.ondemand.com/oauth/authorize --token-url https://<tenant name>/oauth/token --client-id "<client id>" --client-secret "<client secret>"
After that you will be prompted to log on. Now you can display the secrets with the following command:
datasphere config secrets show --host "<your_host>”
This step is crucial as you'll need to save the secrets.json file for later use. Currently, the CLI requires user interaction for the initial login process. By completing this step and saving the secrets.json, you'll be able to automate future logins. The refresh_token validity, which is configured when creating the OAuth client, extends the duration before user re-authentication is needed. This allows for longer, uninterrupted use of the CLI without manual login. In the future, we hope that the log on process will no longer require user interaction, further streamlining automation workflows.
In this local CLI command you can now already test the different CLI commands.
For the API development we created a BTP trial account (https://developers.sap.com/tutorials/hcp-create-trial-account..html). Here we navigate to our Business Application Studio and create a new dev space:
Here we select a “Full-Stack Application Using Productivity Tools” and the “Python-Tools”:
All of our code is available in the following Git repository: https://github.com/zpartner/cli_wrapper. This repository can give you an overview of how the application is structured and developed. For secrets management, we have provided template files that need to be renamed before use. Be sure to update the necessary authentication details in these templates to match your environment.
In the next section, the main points are described.
The following .json files contain important information for our application:
To deploy an application in SAP Business Application Studio (BAS) via Cloud Foundry (CF) on SAP BTP, follow these steps:
After deployment you can also take a look at the generated documentation:
With Postman we can now make the first tests to interact with the API:
To interact now with API endpoints, we need to create a connection first in SAC. We go to connections and create a new HTTP connection. Also add the credentials for the Basic Authentication.
In the next step we create a Multi Action with an API step
In a story we can now integrate this Multi Action and execute it:
Back in the Datasphere we can see now the running instance, triggered from the SAC story.
In this project, we successfully integrated SAP Datasphere task chain automation with SAP Analytics Cloud (SAC) by leveraging a FastAPI wrapper for CLI commands hosted on the SAP Business Technology Platform (BTP). This integration significantly streamlined the process of automating task chains, allowing users to trigger SAP Datasphere operations seamlessly from within SAC. The use of SAC's Multi Actions feature combined with the FastAPI wrapper has enabled a more efficient and automated workflow, improving overall productivity.
Despite the successful implementation, there are several limitations to consider:
Looking forward, we hope SAP introduces a native API that can handle task chain automation without requiring custom development. This would eliminate the need for workarounds like FastAPI wrappers and enhance the native capabilities of SAC. With these improvements, SAP Datasphere and SAC integration could become even more seamless, offering more powerful automation without the need for custom solutions.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
11 | |
8 | |
7 | |
6 | |
5 | |
5 | |
5 | |
4 | |
4 | |
4 |