Skip to Content
Product Information
Author's profile photo Hozumi Nakano

Replicate Data from SAP HANA HDI Container using Replication Flow in SAP Data Intelligence / SAP Datasphere

In this blog post, I will talk about preparing SAP HANA Deployment Infrastructure (HDI) Container to replicate data using Replication Flow in SAP Data Intelligence or SAP Dataphere. As you may know, Replication Flow was introduced in SAP Data Intelligence Cloud in February 2022 and in SAP Datasphere in March 2023. Replication Flow let you replicate multiple datasets from a source to a target in real time with built-in resiliency. There are many great articles about it on SAP Community so I encourage you to read about them.

Prepare a HDI Container using SAP Business Application Studio

If you are new to SAP Business Application Studio, you can refer to various articles such as these blog posts and Developers Tutorial.

First you will create a new Dev Space for SAP HANA Native Application.SAP%20Business%20Application%20Studio%20Dev%20Space%20Creation

SAP Business Application Studio Dev Space Creation

To build a HDI container, you can deploy your project in your workspace.SAP%20Business%20Application%20Studio%20Workspace

SAP Business Application Studio Workspace

Now you can go to SAP BTP Cockpit. In your space, you can see your HDI container you just built in the Instances tab. You can create a Service Key here that can be used to connect from SAP Data Intelligence or SAP Datasphere. If you want to use the underline HANA Cloud in SAP Datasphere, you can refer to this nice blog post.SAP%20BTP%20Cockpit%20Instances

SAP BTP Cockpit Instances

Grant Privileges to the HDI Container Schema

When you enable Delta load type, Replication Flow creates some necessary objects in the source system to keep track of delta changes.

To properly manage these objects, the user that is used to connect from SAP Data Intelligence or SAP Datasphere needs to be granted with the proper privileges. You can refer to HDI Reference to gain the understanding of HDI administration.

Create HDI Administrators

Although this is not Replication Flow specific, I will add some sample SQL statements for administrator creations as a prerequisite to the next step. You can run this on your HANA Cloud database using Database Explore. Replace the schema ‘MYSCHEMA_1’ with your schema name.

-- #### Create Administrators ####
-- Create a Container Group Admin
CREATE USER GROUPADMIN PASSWORD "Welcome1" NO FORCE_FIRST_PASSWORD_CHANGE; 
-- Create a Container Admin
CREATE USER CONTAINERADMIN PASSWORD "Welcome2" NO FORCE_FIRST_PASSWORD_CHANGE;

-- #### Create HDI Container Group Admin ####
-- Grant Container Group Privileges to Container Group Admin
CREATE LOCAL TEMPORARY COLUMN TABLE #PRIVILEGES LIKE _SYS_DI.TT_API_PRIVILEGES;
INSERT INTO #PRIVILEGES (PRINCIPAL_NAME, PRIVILEGE_NAME, OBJECT_NAME) SELECT 'GROUPADMIN', PRIVILEGE_NAME, OBJECT_NAME FROM _SYS_DI.T_DEFAULT_CONTAINER_GROUP_ADMIN_PRIVILEGES;
CALL _SYS_DI.GRANT_CONTAINER_GROUP_API_PRIVILEGES('BROKER_CG', #PRIVILEGES, _SYS_DI.T_NO_PARAMETERS, ?, ?, ?);
DROP TABLE #PRIVILEGES;

-- #### Create HDI Container Admin ####
-- Connect as Container Group Admin
CONNECT GROUPADMIN PASSWORD "Welcome1";
-- Grant Container Privileges to Container Admin
CREATE LOCAL TEMPORARY COLUMN TABLE #PRIVILEGES LIKE _SYS_DI.TT_API_PRIVILEGES; 
INSERT INTO #PRIVILEGES (PRINCIPAL_NAME, PRIVILEGE_NAME, OBJECT_NAME) SELECT 'CONTAINERADMIN', PRIVILEGE_NAME, OBJECT_NAME FROM _SYS_DI.T_DEFAULT_CONTAINER_ADMIN_PRIVILEGES; 
CALL _SYS_DI#BROKER_CG.GRANT_CONTAINER_API_PRIVILEGES('MYSCHEMA_1', #PRIVILEGES, _SYS_DI.T_NO_PARAMETERS, ?, ?, ?); 
DROP TABLE #PRIVILEGES;

Grant Schema Privileges to the User Connecting from SAP Data Intelligence / SAP Datasphere

Replication Flow will create the triggers in the HDI container schema. It needs TRIGGER privilege to properly clean them up when the replication flow is undeployed. To allow granting the privilege to the user, we first need to set the HDI configuration parameter “api.enable_flowgraph_access” to true, which you can find in the documentation SAP HDI Configuration Parameters. Then you can grant the schema privilege to the user.

-- #### Set HDI Configuration Parameter ####
-- Connect as Container Admin
CONNECT CONTAINERADMIN PASSWORD "Welcome2";
-- Prepare configuration parameters table
CREATE TABLE MY_CONFIG_PARAMETERS like _SYS_DI.TT_PARAMETERS;
INSERT INTO MY_CONFIG_PARAMETERS(KEY, VALUE) values ('api.enable_flowgraph_access', 'true');
-- Prepare parameters table
CREATE TABLE MY_PARAMETERS like _SYS_DI.TT_PARAMETERS;
-- Call procedure
CALL MYSCHEMA_1#DI.CONFIGURE_CONTAINER_PARAMETERS(MY_CONFIG_PARAMETERS, MY_PARAMETERS, ?, ?, ?);
DROP TABLE MY_CONFIG_PARAMETERS;
DROP TABLE MY_PARAMETERS;

-- #### Grant Schema Privilege to HDI Container User ####
-- Grant TRIGGER privilege to the container user as Container Admin
CREATE LOCAL TEMPORARY COLUMN TABLE #PRIVILEGES LIKE _SYS_DI.TT_SCHEMA_PRIVILEGES; 
INSERT INTO #PRIVILEGES ( PRIVILEGE_NAME, PRINCIPAL_SCHEMA_NAME, PRINCIPAL_NAME ) VALUES ( 'TRIGGER', '', 'MYSCHEMA_1_3GYDEAR6R1Q6FRX4TXAZI4NPU_RT' );
CALL MYSCHEMA_1#DI.GRANT_CONTAINER_SCHEMA_PRIVILEGES( #PRIVILEGES, _SYS_DI.T_NO_PARAMETERS, ?, ?, ?);
DROP TABLE #PRIVILEGES;

Create a Connection to the HDI Container in SAP Data Intelligence / SAP Datasphere

To create a connection in SAP Data Intelligence, go to Connection Management. Using the credentials you obtained from the SAP BTP Cockpit above, create a connection and click Test Connection to verify it.SAP%20Data%20Intelligence%20SAP%20HANA%20Connection

SAP Data Intelligence SAP HANA Connection

Similarly, to create a connection in SAP Datasphere, go to Connections. Enter the connection details and save the connection. You can also verify the connection after saving.SAP%20Datasphere%20SAP%20HANA%20Connection

SAP Datasphere SAP HANA Connection

Deploy and Run the Replication Flow

To create a replication flow in SAP Data Intelligence, go to Modeler. Create a Replication Flow, select the source and target properties and create a task with your dataset.

You can deploy the replication flow, run it, and go to Monitoring from the top toolbar to view the status.Replication%20Flow%20Editor%20in%20Data%20Intelligence%20Modeler

Replication Flow Editor in SAP Data Intelligence Modeler

Similarly, to create a replication flow in SAP Datasphere, go to Data Builder. Create a Replication Flow, select the source and target properties with your dataset.

You can deploy the replication flow, run it, and go to Data Integration Monitor from the top toolbar.Replication%20Flow%20in%20SAP%20Datasphere

Replication Flow Editor in SAP Datasphere Data Builder

When you run the Replication Flow with Delta load type enabled, some internal objects are created in your source system.  These objects are cleaned up when you undeploy the replication flow in SAP Data Intelligence or stop it in SAP Datasphere. Please refer to the documentation Clean Up Source Artifacts for additional information.Triggers%20created%20in%20HDI%20Container%20for%20Replication%20Flow

Triggers created in HDI Container for Replication Flow

Summary

In this article, I have walked through the steps to setup a HDI container and consumed in Replication Flow in SAP Data Intelligence and SAP Datasphere. For additional information about supported connections, you can refer to the product documentation for SAP Data Intelligence and SAP Datasphere.

Replication Flow works similarly in SAP Data Intelligence and SAP Datasphere but there are some differences. Please refer to the SAP Note and SAP Datasphere Roadmap to see the planned future enhancements. As always, if you have questions, you can post your questions on SAP Community.

Assigned Tags

      8 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Benedict Venmani Felix
      Benedict Venmani Felix

      Hello Hozumi,

      Nice blog. Thank you for the detailed info.

      I do not understand the step where you 'Grant Schema Privileges to the User Connecting from SAP Datasphere', and the step 'SAP Datasphere SAP HANA Connection'.  What is the user name that is granted the privilege and connects to Datasphere?

      Can you please explain what is grant privilege step please?

       

      -Benedict

      Author's profile photo Hozumi Nakano
      Hozumi Nakano
      Blog Post Author

      Hi Benedict, you can get the credentials from your service key you can get in the BTP Cockpit as you can see in the screenshot SAP BTP Cockpit Instances from above. Hope that answers your question.

      Author's profile photo Michael Cocquerel
      Michael Cocquerel

      What's the purpose of user HDIADMIN ? I do not see any place where you are using it.

      Author's profile photo Hozumi Nakano
      Hozumi Nakano
      Blog Post Author

      Hi Michael, you can refer to Set up an SAP HDI Container with some examples. You can optionally create your own container group and move the container to the group as a HDI admin. I did not include that part in my examples, so that was confusing! I removed the creation of HDIADMIN from my example.

      Author's profile photo sarthak srivastava
      sarthak srivastava

      Hello Hozumi Nakano ,

      If we connect to HANA HDI Container to SAP Datasphere.

      And use HANA Calculation Views from container in Datasphere Graphical Views.

      Will HANA Calculation view's data be available in real-time or do I need to create a replication flow

      on top of the Calculation View to get the data refreshed from HANA CV to Datasphere.

       

      Thanks & Regards,

      Sarthak Srivastava

      Author's profile photo Hozumi Nakano
      Hozumi Nakano
      Blog Post Author

      Hi Sarthak, if you are directly accessing your HDI container, you get the current data from your Calculation View in your Graphical View. You can use Replication Flow if you want to move your data to a local table.

      Author's profile photo Sharath Prakash
      Sharath Prakash

      Hi Hozumi,

       

      Thanks for this brilliant blog. This overcomes the challenge and pain point of handling source artifacts clean up and necessity of granting "CREATE ANY" privilege in design time roles of HDI containers.

      One additional step we had to do after following above steps. We had to grant select privileges on the tables which was replicated from HDI containers.

      Thanks.

      Author's profile photo Hozumi Nakano
      Hozumi Nakano
      Blog Post Author

      Thank you Sharath! And thanks for sharing the additional step. I am glad you got this working 🙂