1

Replicate artifacts from an HDI Container in SAP Business Application Studio to...

 1 year ago
source link: https://blogs.sap.com/2022/11/17/replicate-artifacts-from-an-hdi-container-in-sap-business-application-studio-to-sap-hana-on_premise/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
November 17, 2022 4 minute read

Replicate artifacts from an HDI Container in SAP Business Application Studio to SAP HANA On_Premise

The SAP HANA Deployment Infrastructure (HDI) is a service layer of the SAP HANA database and helps to create runtime database objects from design-time artifacts.

It uses containers to store design-time artifacts and the corresponding deployed run-time objects.

Inside the database, the HDI container is represented as a schema but is owned by a technical user and isolated from other database objects. Only local object access inside the container is allowed and to access objects outside the container explicit grants is required from the object owner.

In this blog, you will learn to create HDI module for database content in the BAS, enable access to the schema of an HDI container to a database object consumer and replicate the object.

Create Hana Database Project

1. Create SAP HANA Native Application Dev space

CC_PIC1.png

2. Once the dev space is running, click the dev space name to open it

CC_PIC2.png

3. From Welcome tab, click Start from template to create a new project

CC_PIC3.png

4. Choose SAP HANA Database Project and click Start

CC_PIC4.png

5. Provide the project name as DEMO and click Next

CC_PIC5.png

6. Retain the module name as default “db” and click Next

7. Enter schema name “MY_SCHEMA” and choose Database version as “HANA Cloud” and click Next

CC_PIC6.png

8. To bind your project to your SAP HANA Cloud, SAP HANA database, you must log on to a Cloud Foundry environment in the SAP BTP subaccount. Once the login is complete, your organization and space are automatically selected

Provide all the necessary details and click on Finish

CC_PIC7-2.png

9. Once the project is complete,Press the Open in New Workspace button in this success message to open the new project in the IDE

CC_PIC8_Edited-2.png

Create database artifacts

1. Navigate to View > Find Command > Create Database Artifact > Choose Artifact type as Table > Provide Artifact Name > Create

CC_PIC9-1.png

2. Create table with required details and click Deploy in SAP HANA PROJECTS View

CC_PIC10-1.png

3. Create CSV file

CC_PIC11.png

4. Enter the data in CSV file and click Deploy in SAP HANA PROJECTS View

CC_PIC12-1.png

5. Create hdbtabledata to import the data from CSV into Table

CC_PIC13.png

6. Define the mappings in the hdbtabledata file and click Deploy in SAP HANA PROJECTS View

CC_PIC14.png

Grant Access to an SAP HDI Container’s Schema

To grant access privileges for the entire container schema where the database objects are located to a database object consumer USER, perform the following steps.

Grant access to the HDI container’s schema by executing the below:

1.  In DBX, connect to HDI container and Open SQL Admin Console

CC_PIC15.png

2. Grant access to the HDI container’s schema by executing the below statements

CREATE LOCAL TEMPORARY COLUMN TABLE #PRIVILEGES LIKE _SYS_DI.TT_SCHEMA_PRIVILEGES;
INSERT INTO #PRIVILEGES ( PRIVILEGE_NAME, PRINCIPAL_SCHEMA_NAME, PRINCIPAL_NAME ) VALUES ( ‘SELECT’, ”, ‘USER’ );
CALL C#DI.GRANT_CONTAINER_SCHEMA_PRIVILEGES( #PRIVILEGES, _SYS_DI.T_NO_PARAMETERS, ?, ?, ?);
DROP TABLE #PRIVILEGES;
CC_PIC19.png

3. Confirm that the USER can now access the database objects in the container’s schema.

CC_PIC17.png

Replicate artifacts from HDI container into SAP HANA On Premise

Create remote source to the Hana Cloud Database

1. In an SQL console, connected to the SAP HANA on-premise database, create a remote source to the HC database with the adapter name hanaodbc:

CREATE REMOTE SOURCE <HANA1> ADAPTER “hanaodbc”

CONFIGURATION ‘Driver=libodbcHDB.so;ServerNode=<HANA_Cloud_endpoint>;

encrypt=TRUE;’

WITH CREDENTIAL TYPE ‘PASSWORD’ USING ‘user=<user_name>;password=<password>’;

2. Create the virtual table VT in the target system based on the table “EMPLYOEE DETAILS” in the “MY_SCHEMA” schema of the source system

CREATE VIRTUAL TABLE VT AT “HANA1″.”<NULL>”.”MY_SCHEMA”.”EMPLOYEE_DETAILS”;

3. Create the replica table RT using the virtual table VT as the source for the definition

CREATE COLUMN TABLE RT LIKE VT;

4. Create a remote subscription, specifying VT as the virtual table on which the changes are to be captured and RT as the target table to which they are to be applied

CREATE REMOTE SUBSCRIPTION SUB ON VT TARGET TABLE RT;

5. Activate replication using the ALTER REMOTE SUBSCRIPTION statement with the DISTRIBUTE command

ALTER REMOTE SUBSCRIPTION SUB DISTRIBUTE;

6. Check the data replicated on to the target table

SELECT * FROM RT;

7. Deactivate replication and Drop the replication when it is no longer needed

ALTER REMOTE SUBSCRIPTION SUB RESET;

DROP REMOTE SUBSCRIPTION SUB;

Conclusion

In this blog we have seen how to grant access to HDI’s schema, setup remote table replication based on the SDA hanaodbc adapter, create a virtual table, a target table, a remote subscription, and then activate replication on the target system.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK