Skip to Content
Author's profile photo Dmitry Marinin

Some ways to replace nodes in SAP HANA graphical calculation view without losing metadata

Problem description: when you try to replace node in graphical calculation view, SAP HANA Studio function “Replace with” do not offer all possible options. If you delete bottom node of calculation view from top node, all reference columns will be also removed from all connected top nodes.


First of all you should use development perspective. If you use Modeler perspective you can easily migrate your views to development perspective. If you try to apply “Check Out and Import Projects” operation (Development perspective->Repositories) on package created in Modeler

/wp-content/uploads/2016/01/1_870062.png

you will get an error “No projects are found to import”:

/wp-content/uploads/2016/01/2_870064.png

To fix it you should open Development perspective->Repositories, add .project file (in attachment) to your package, fix package name inside .project file and

activate .project file:


<?xml version=“1.0” encoding=“UTF-8”?>

<projectDescription>

  <name>A00_MOD_PERSP_PROJ</name>


Package cannot be structural.  You can unmark this option using edit package.


After these actions you can Check Out and Import Project and use Project explorer for development:

/wp-content/uploads/2016/01/3_870074.png

Let’s consider the next graphical calculation view that includes projections and join:

/wp-content/uploads/2016/01/4_870076.png

But what if now you need to aggregate Projection_2 data and include result in Join_1:

/wp-content/uploads/2016/01/5_870077.png

You are not able to use “Replace with” functionality:

/wp-content/uploads/2016/01/6_870078.png


But you can open Calculation view with text editor:

/wp-content/uploads/2016/01/7_870079.png

Find Join_1 metadata:

    <calculationView xsi:type=”Calculation:JoinView” id=”Join_1″>

      <viewAttributes>

        <viewAttribute id=”id”/>

        <viewAttribute id=”name_firstName”/>

        <viewAttribute id=”name_middleName”/>

        <viewAttribute id=”name_lastName”/>

        <viewAttribute id=”orgUnit”/>

        <viewAttribute id=”address_id”/>

        <viewAttribute id=”street”/>

        <viewAttribute id=”city”/>

      </viewAttributes>

      <calculatedViewAttributes/>

      <input node=”#Projection_1″>

        <mapping xsi:type=”Calculation:AttributeMapping” target=”id” source=”id”/>

        <mapping xsi:type=”Calculation:AttributeMapping” target=”name_firstName” source=”name_firstName”/>

        <mapping xsi:type=”Calculation:AttributeMapping” target=”name_middleName” source=”name_middleName”/>

        <mapping xsi:type=”Calculation:AttributeMapping” target=”name_lastName” source=”name_lastName”/>

        <mapping xsi:type=”Calculation:AttributeMapping” target=”orgUnit” source=”orgUnit”/>

        <mapping xsi:type=”Calculation:AttributeMapping” target=”address_id” source=”address_id”/>

      </input>

      <input node=”#Projection_2″>

        <mapping xsi:type=”Calculation:AttributeMapping” target=”street” source=”street”/>

        <mapping xsi:type=”Calculation:AttributeMapping” target=”city” source=”city”/>

        <mapping xsi:type=”Calculation:AttributeMapping” target=”address_id” source=”id”/>

      </input>

      <joinAttribute name=”address_id”/>


Replace “Projection_2” on “Aggregation_1”

      <input node=”#Aggregation_1″>

        <mapping xsi:type=”Calculation:AttributeMapping” target=”street” source=”street”/>

        <mapping xsi:type=”Calculation:AttributeMapping” target=”city” source=”city”/>

        <mapping xsi:type=”Calculation:AttributeMapping” target=”address_id” source=”id”/>

        </input>


And activate the view (you can use “Reset to active version” if something goes wrong). Then open the view with SAP HANA View editor:

/wp-content/uploads/2016/01/8_870083.png

/wp-content/uploads/2016/01/9_870084.png

Another very useful approach concerning new view development – add Technical Union before final Aggregation:

/wp-content/uploads/2016/01/10_870085.png

So you can easily add another final node (or nodes) in place of Join_1 and then remove Join_1 without losing any metadata.

Assigned Tags

      8 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Former Member
      Former Member

      Wow!! Amazing!!! Thanks Dmitry

      Author's profile photo Dmitry Marinin
      Dmitry Marinin
      Blog Post Author

      Enio, you are welcome!

      Author's profile photo Former Member
      Former Member

      Good. Makes it clearer.

      Author's profile photo Former Member
      Former Member

      Very useful. Thank you!

      Author's profile photo Shaun Smith
      Shaun Smith

      Thanks for this! It is very useful!

      Author's profile photo ARPAN PARNAMI
      ARPAN PARNAMI

      Awesome Very good information.

      Author's profile photo Samuel Muñoz
      Samuel Muñoz

      Hola, gracias por la información, es muy útil.

      Author's profile photo Kenneth Murray
      Kenneth Murray

      2022 here and still had to use this hack to replace a node...  Thanks