Schema Mapping

In the article SAP HANA Modeling Introduction and SAP HANA Calculation View we explained the basics of SAP HANA data modeling. We also learnt how to create modeling views in Build Your First SAP HANA Model in 10 Minutes 
In this article we will learn about a very important concept in HANA modeling - Schema mapping.

Schema mapping is required when moving SAP HANA objects from one system to another system, say from Development system to Test System, or Test System to Production System.

To understand Schema mapping, we first have to understand schema, authoring schema and physical schema. Let's check them one by one.

The concept of Authoring schema and Physical schema:

What is schema?
A database schema is a way to logically group objects such as tables, views, stored procedures etc. You can think of a schema as a container of objects.

Authoring schema:
An authoring schema (logical schema) is the database schema used in the design time views. For example, this is the database schema that is used in the content development system.

Example:
Suppose we are developing some modeling views in Development System (DEV). The schema present in the Development system is DEV_SCHEMA, which contains all the required tables. The tables in the schema DEV_SCHEMA is used in modeling views creation. So DEV_SCHEMA is Authoring Schema.

Physical schema:
When contents are moved to a different system, the target system might contain a different schema name. The schema available in the target system, which contains required tables is called physical schema.

Example:
Suppose the content created in the Development System (DEV) is moved to Production System (PROD).
It is very likely that the schema name is different in customer system. Say for example the required tables which were present in DEV_SCHEMA in development system, are present in a schema PROD_SCHEMA in production system.
In this case, the physical schema is PROD_SCHEMA.

Schema Mapping in SAP HANA:

Schema mapping is required when moving SAP HANA objects from one system to another system, say from Development system to Test System, or Test System to Production System.

As mentioned earlier, suppose we are moving components from Development System (DEV) to Production System (PROD).
The tables in DEV reside in DEV_SCHEMA and the same tables reside in PROD system in PROD_SCHEMA schema. If an attribute view is transported from DEV to PROD, it will not work because the schema name is referenced in the definition of attribute view. In order for the promoted objects to work in PROD, schema mapping needs to be set up in the target system.
In this scenario, the schema mapping to be created is

Authoring Schema Physical Schema
DEV_SCHEMA PROD_SCHEMA

A Real time example:

Consider a source system, SAP, with an information object "AttributeView1". This refers to the table MARA in the SAP_ERP physical database schema.
There is a target system, Customer, with the physical database schema EMEA. The table MARA is in the schema EMEA in Customer system.
After you import content, the object "AttributeView1" cannot be activated in the Customer system, because it still refers to the SAP_ERP schema.

"AttributeView1" in the Customer system currently refers to SAP_ERP. To be able to activate the object, you need to modify the mapping of "AttributeView1" in the Customer system.
To do this, a mapping is created in the target system Customer between the authoring and physical schema as follows

Authoring Schema Physical Schema
SAP_ERP EMEA


How to create schema mapping:
  1. In Modeler Perspective, go to Help in Menu bar and select Quick Launch.
  2. Click on Schema Mapping under Setup section.
  3. Add Authoring schema name. For example SAP_ERP.
  4. Add Physical schema name. For example EMEA .


Few Important Points about schema mapping:
  • Schema mapping is only relevant for modeling views. Not procedures or script-based calculation views. You need to map the references of the script-based calculation views and procedures manually, that is, by changing the script if the tables are qualified with the schema.
  • You can map several authoring schemas to the same physical schema. For example, content objects delivered by SAP refer to different authoring schemas, whereas in the customer system, all these authoring schemas are mapped to a single physical schema where the tables are replicated.
  • The mapping between authoring and physical schemas is stored in the configuration table "_SYS_BI"."M_SCHEMA_MAPPING"
Continue reading:

No comments:

Post a Comment