Skip to Content
Technical Articles

Migrate Calculation Views from On-Premise SAP HANA to SAP HANA Cloud – Part 1

(Japanese version here)

Overview:

SAP HANA Cloud was released in March 2020 and many of you, especially SAP HANA On-Premise users, are interested in the next generation “Database as a Service” product. The objective of this blog series is to share the experience of migration test from SAP HANA On-Premise to SAP HANA Cloud.

Please note that SAP has plan to release migration tool (the planned first scope is from SAP Cloud Platform, HANA Service (HANA as a Service / HaaS) to SAP HANA Cloud), this means probably the steps described in this blog will be obsolete in the future.

For those who wants to start working with SAP HANA Cloud, please refer to the blog by Maxime Simon.

Steps:

There are 3 tables (SO_HEADER, SO_ITEM and MD_PRODUCTS) in a classical DB schema “SALES” and 2 Calculation Views (CV_SALES and CV_PRODUCTS) in package “SALES”. Steps to migrate them are as follows.

Step1. Migrate classical Calculation Views to XSA HDI Container objects
Step2. Import the migrated objects to SAP HANA Cloud
Step3. Transfer data from On-Premise to Cloud.

 

Environment:

On Premise : SAP HANA 2.0 SPS04 Revision 42
Cloud: SAP HANA Cloud 4.00.000.00.1583243463 (Last Update March 3, 2020)

 

So let’s start the migration! The first step proceeds as follows.

  1. Check the data model
  2. Prepare the migration tool
  3. Convert the Calculation Views to XSA (HDI) model
  4. Import the migrated model into HDI Container
  5. Migrate tables into HDI Container

 

1. Check the data model

There are 3 tables in “SALES” schema.

There are 2 Calculation Views in “SALES” package, DIMENSION type “CV_PRODUCTS” and CUBE with Star Join type “CV_SALES”.

Package “SALES” is assigned to a Delivery Unit “SALES”.

 

2. Prepare the migration tool

Download and setup the migration tool with following the SAP Help.

First, download “XSAC Migration 1” from SAP Support Portal.

Then, unzip the ZIP file and place it to any folder.

Set the environment variables.

 

3. Convert the Calculation Views to XSA (HDI) model

Convert the classical Calculation Views to XSA model using the installed migration tool.

First, create a folder where migrated objects are exported. In this blog, I created “C:\tmp\xs-migration”.

Then, execute the command below to convert the objects.

xs-migration --target-dir "C:\tmp\xs-migration\Sales" SALES,SAP_JAPAN

* Please note that the target folder (“Sales” in this case) must not be existed
* “SALES,SAP_JAPAN” is a name of Delivery Unit and the vendor of it, this means the tool converts each Delivery Unit.

~~~~

Successfully finished! I found files are generated in the specified folder.

Now, let’s see “report.html”. We can see the details of the generated files.

Finally, compress the generated source file (folder db > src) into a ZIP file.

 

4. Import the migrated model into HDI Container

4.1 Import the converted objects into a HDI Container

Logon to HANA Cloud using Web IDE for SAP HANA and create a target project (“SALES”). And then, import the ZIP file, which was created in the previous step, into “src” folder under the project.

Choose the ZIP file.

Click “Import”.

The models are successfully imported into XSA.

4.2 Create Synonym

The new Calculation Views are now ready to be deployed to the HDI Container. However tables are not converted yet, this means tables and data are still in the classical schema “SALES”. Therefore we need to create synonym so that Calculation Views in HDI Container can access to the classical schema. Please refer to SAP Help and other SAP Blog for details, I will share the steps in the followings.

4.2.1 Create Role & User

Create two roles and a DB user for Grant service using SAP HANA Studio. Then, assign the roles to the user.

CREATE ROLE "sales::source_schema";
GRANT SELECT, EXECUTE ON SCHEMA SALES TO "sales::source_schema";
CREATE ROLE "sales::source_schema_g";
GRANT SELECT, EXECUTE ON SCHEMA SALES TO "sales::source_schema_g" WITH GRANT OPTION;
CREATE USER USR_GRANTOR password XXXXXXX no force_first_password_change;
GRANT "sales::source_schema","sales::source_schema_g" to USR_GRANTOR with admin option;

4.2.2 Register Grantor service to XSA

Register Grantor service to XSA using XSA CLI. To do this, logon to DB server and execute the command below.

xs cups EPM_XXX-table-grantor –p "{"host":"hostname.com","port":"30015","user":"USR_GRANTOR","password":"XXXXXX","driver":"com.sap.db.jdbc.Driver","tags":["hana"]}"

4.2.3 Edit mta.yaml

Open mta.yaml with Code Editor and add the grantor-service which was registered above.

4.2.4 Create .hdbgrants file

Create a new file with extension “.hdbgrants” under “src”.

Insert the definition as follows, then save and deploy the file.

{
	"grantor-service": {
		"object_owner": {
			"roles": [
				"sales::source_schema_g"
			]
		},
		"application_user": {
			"roles": [
				"sales::source_schema"
			]
		}
	}
}

4.2.5 Configure Synonym

Open the “.hdbsynonym” file under the “src” folder to configure synonym definition. This file was created by the Migration tool. Click “…” in the “Object Name” column.

For “External Services”, select the grantor service which was created in the previous step. Then input (part of) the table name and choose the actual table from the “Results” list. (In this case, choose “MD_PRODUCTS” table in “SALES” schema)

Repeat this for all tables, and then save and build the “.hdbsynonym” file.

You can confirm that synonyms are created and they can be accessed with SQL statement using Database Explorer.

4.3 Build the imported models

Finally, build the imported models.

You can confirm that Calculation Views are created and you can access them with SQL statement from Database Explorer.

The Calculation Views has been successfully migrated to the XSA HDI Container!!

 

5. Migrate the tables into HDI Container

It is OK to keep the tables in classical schema, however this blog will also migrate the tables into the HDI Container (the schema managed by the container).

5.1 Create table using HDBTable (.hdbtable)

Create HDBTable DDL files (.hdbtable) and build them. Please refer to the SAP Help for HDBTable syntax reference.

* Do not use CDS Table because SAP HANA Cloud does not support CDS.

5.2 Transfer Data

Transfer data from a table (synonym) in the classical schema to a table in HDI Container using SQL statement.

insert into "SALES_1"."SALES::HDI_MD_PRODUCTS" select * from "SALES_1"."SALES::MD_PRODUCTS";

5.3 Edit synonym definition

Edit “.hdbsynonym” file as same as step 4.2.5, and then save and build the file. Synonyms needs to refer to the tables which are created step 5.1.

Check the Calculation View again and confirm that the data can be retrieved.

 

Fist step has been finished and now the Calculation Views and data are in HDI Container! In the next blog, I will migrate the models to SAP HANA Cloud.

 

2 Comments
You must be Logged on to comment or reply to a post.