6

Understanding the development process of calculation view in HANA 2.0 XSA enviro...

 1 year ago
source link: https://blogs.sap.com/2020/11/23/understanding-the-development-process-of-calculation-view-in-hana-2.0-xsa-environment-using-web-ide/
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 23, 2020 5 minute read

Understanding the development process of calculation view in HANA 2.0 XSA environment using Web IDE

0 0 1,118

In this blog I will discuss about the development lifecycle process and steps of develop an calculation view in HANA 2.0 XSA environment using Web IDE.

In HANA 1.0 till SPS12 we have developed Calculation view with the catalog object tables from a schema also the operation available for development like Join, Union is very less.

In HANA 2.0 XSA environment using web IDE we will get more operation option like NonEqui Join, Graph, Rank, Rank, Hierarchy Function, Anonymization etc. which are not  available in HANA studio. Those option any body can easily adopt and use in their view development. I will not discuss this in my blog.

My objective of this blog is to discuss the part which is the critical one, i.e. using data or table from same HDI container, from different or cross HDI container or from XS classic schema. When I started my development activity initially 2 year before in XSA environment using web IDE this cross contains access troubles me lot. I want to create a smoother path to the the developer or modeler to avoid mistakes and optimize time using my blog which is the main goal.

Please find the process below –

## Prerequisite Steps:

This prerequisite will help you to develop calculation view in optimize way without any mistake.

1.Create an MTA project : First we need to create an MTA project in our workspace using Web IDE.

CV-1.png

2. Create a DB Module : Create a DB module inside the MTA project.

CV0.png

3.Identify the tables: Identify all the tables one by one.

4.Tables exists in the same HDI container :  If all the identified tables exists in the same HDI container then no action needed.

5.Tables exists in the Different  HDI container in Same server Instance:

Please find the below steps :

A. Add the source table (Suppose T1) DB which deployed in different HDI container as a depended of a target DB  in MTA.YAML file where we will create the Calculation view and use the source table T1 .

Note : while creating the source DB please provide a key and service while adding in the MTA files.

Source DB definition :

  - name: source_db
    type: hdb
    path: source_db
    requires:
      - name: hdi_source_db
        properties:
          TARGET_CONTAINER: '~{source-container-name}'
resources:
  - name: hdi_source_db
    parameters:
      config:
        schema: DEMO_USER_001
    properties:
      user-container-name: '${service-name}'
	  type: com.sap.xs.hdi-container
modules:
  - name: trgt_db
    type: hdb
    path: trgt_db

    requires:
      - name: hdi_source_db
        group: CROSS_CONTAINER
        properties:
          key: hdi-source-service
          service: '~{source-container-name}'

Same thing you can achieve via MTA graphical editor –

@Source DB :

Source-DB.png

@Target DB :

Target-DB.png

B. Create a  .hdbgrants  file  inside cfg folder (configuration) :

create a .hdbgrants configuration file inside your MTA project under DB module src package. The code should be similar like the below in which you need to changed the role name as per the role mentioned in the .hdbrole configuration file of the required table’s source HDI container.


***********************************
targetuser.hdbgrants:
***********************************
{
   "hdi-user-service": {
     "object_owner": {
       "container_roles":["role1#"]
     },
     "application_user": {
       "container_roles":["role"]
     }
   } 
}

C.  Create a Synonym inside src folder with below code example –

***************************************
targetuser.hdbsynonym
***************************************

{
  "source_db_emp_cv": {
    "target": {
      "object": "surce_db::employee"
    }
  }
}

Note : “source_db::employee” is the calculation view we have created in the source Database.

D. Create a targetuser.hdbsynonymconfig  file  inside cfg folder (configuration) :

*****************************************
 File targetuser.hdbsynonymconfig
*****************************************

{
  "source_db_emp_cv": {
    "target": {
      "object": "source_db::employee",
	  "grantor": "hdi-user-service"
    }
  }
}

E. Build the MTA application  and create a calculation view and consume the employee table and you will be able to see the employee data.

joinpane-1-1.png

6.Table exists in a XS classic schema or Outside the Server Instance : Add the Source XS Classic schema as a service to the target database where we will create the Calculation view.

service-1.png

Similar to the step and architecture . we need to create .hdbgrants file in the target HDI (Where creating calculation view) but we do not put # after the role to indicate that the table is from XS classic schema not from an HDI container.

grant-3.png

## Main Steps to create Calculation view –

1.Create a calculation view : Create a view from the wizard.

CV1.png
cv2.png

2.  Now we are in the workspace pane and added  join node.

joinpane-1.png

3. Add data source. then the popup will be open from there select the external service to choose the source. This step will apply both for Different HDI and XS Classic schema scenario.

External-Services1-1.png

4. The chick on the create synonym.

symn1.png

5. In this step we have to provide the Object Owner Role and Application User Role which we have create in the .hdbgrants file in the prerequisite steps. click Finish.

role12.png

6.Tow table from different source will appear in the join node. Then add the joins as per condition and push the column  in the output of the semantics one by one which is common with HANA Studio development which I am not discussion in details.

JP.png

7. Save and build the view.

CV9.png

8. Go to the database container and data preview the CV. you can see the data.

dv.png

Hope my blog will help to develop Calculation view in a very smooth way in different container scenario……..


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK