Thursday, 19 March 2020

Creating Reports via Calculation Views Using Cube – Star Joins

Introduction:


In this blog post, we will discuss on how to create reports via calculation views using cube – Star joins.

OUTPUT:

SAP HANA, SAP Cloud Platform SAP HANA Studio, Calculation View


This can be achieved in three steps.

1. Create the calculation view.
2. Configure the destination
3. Consume via a SAPUI5 application.

Create the calculation view:

Start the database.

Go to SAP HANA Web based development workbench.

SAP HANA, SAP Cloud Platform SAP HANA Studio, Calculation View

Create a schema in the catalog.

SAP HANA, SAP Cloud Platform SAP HANA Studio, Calculation View

Click on Editor in the workbench.

Right click on content and create a new application and create dummy_pkg.

SAP HANA, SAP Cloud Platform SAP HANA Studio, Calculation View

Consider we have 3 tables with following data.

TABLE 1: DIMENSION TABLE

SAP HANA, SAP Cloud Platform SAP HANA Studio, Calculation View

TABLE 2:

SAP HANA, SAP Cloud Platform SAP HANA Studio, Calculation View

TABLE 3:

SAP HANA, SAP Cloud Platform SAP HANA Studio, Calculation View

Note: Its necessary to create calculation view with dimension to have star join.

Right click on the package created and select new -> Calculation view.

SAP HANA, SAP Cloud Platform SAP HANA Studio, Calculation View

Give the details as follow and click on create

SAP HANA, SAP Cloud Platform SAP HANA Studio, Calculation View

Double click on the calculation view and you will find the following.

Go to projection and click on the + button to add the Data source.

Here our data source is table 1.

Select the fields and click on “Add to output”.

Save and activate it.

SAP HANA, SAP Cloud Platform SAP HANA Studio, Calculation View

Thus, the calculation view for Table 1 is created.

Now to create the calculation view with star join – connect the calculation  view created above, table 2 and table 3.

Again Right click on the package created and select new -> Calculation view.

SAP HANA, SAP Cloud Platform SAP HANA Studio, Calculation View

Give the details as follows

SAP HANA, SAP Cloud Platform SAP HANA Studio, Calculation View

Click on projection and add the data source as table2 and Add the required fields to output.

x

Now to join these projection introduce a join in between them and connect the projections with primary key and also add the required fields to output.

Now connect the join to the star join and also by clicking on the + symbol add the Calculation view created using dimension above and map them with primary key and add the required fields to output.

Now add the measures to semantic.

SAP HANA, SAP Cloud Platform SAP HANA Studio, Calculation View

Now run the calculation view created via star join.

SAP HANA, SAP Cloud Platform SAP HANA Studio, Calculation View

Thus we could find the different columns from calculated view and tables are mapped inside a single view.

Now create xsodata file inorder to consume the data as service which will be consumed in a UI5 application.

SAP HANA, SAP Cloud Platform SAP HANA Studio, Calculation View

Run the xsodata file and your service will be as below.

SAP HANA, SAP Cloud Platform SAP HANA Studio, Calculation View

So here is our xsodata service to be consumed via UI5 application.

Configure the destination:

◉ Configure the destination as follows.

SAP HANA, SAP Cloud Platform SAP HANA Studio, Calculation View

Create an SAP UI5 application via sap web IDE

Click file -> new project from template and click on sap ui5 application.

Create the view as follows

SAP HANA, SAP Cloud Platform SAP HANA Studio, Calculation View

Create the controller as follows

SAP HANA, SAP Cloud Platform SAP HANA Studio, Calculation View

Configure the neo app.json as follows

SAP HANA, SAP Cloud Platform SAP HANA Studio, Calculation View

Run the SAPUI5 Application and the output will be obtained as follows.

SAP HANA, SAP Cloud Platform SAP HANA Studio, Calculation View

No comments:

Post a Comment