Wednesday, 2 August 2017

Implementing Graphical Hierarchy view for Profit Center in SAP HANA

This blog is about Standard hierarchy ,Standard hierarchy is a tree structure for grouping all profit centers which belong to a controlling area. When creating a Profit Center, you must assign it to a group (node) of the standard hierarchy.

Below is the sample ProfitCenter Hierarchy how it looks in SAP ECC.



SAP HANA, Calculation views

There are two tables in SAP for groups in standard hierarchy.
  • SETNODE
  • SETLEAF
To build a standard hierarchy, we have to read SETNODE for each level of the hierarchy and build the tree.

In SAP, there are many different groups such as Cost Center Group, Cost Element Group, and Profit Center Group etc. Each and every group is identified with unique code in field SETCLASS. For Profit Center it is ‘0106’.

To get the description texts, join the text tables SETHEADERT and CEPCT for Profit Center text to SETNODE and SETLEAF tables.

All the nodes, with subsets are included in SETNAME field in SETNODE table. SETNAME in SETNODE becomes the parent and SETNAME (joined to SUBSET in SETNODE) in SETLEAF is the child.

First create a base view to get Nodes, Sub Nodes and Profit Centers and there descriptions.

This is the overview of the Base View.

SAP HANA, Calculation views

Join_1:Text join SETNODE table  to SETHEADERT table with Language column as LANGU from which we will get Nodes and related Descriptions.

SAP HANA, Calculation views

Join_2: Text join VALFROM to PRCTR with language column as SPRAS here we will get Profit Centers and related Descriptions.

SAP HANA, Calculation views

Union Join_1 and Join_2, create a target column for SubSet and map SUBSETNAME from Join_1,this will be used in main view.

SAP HANA, Calculation views

In SAP HANA there is no standard way to create this type of Hierarchy(In SAP HANA we have simple Level and Parent Child hierarchy)Create the Profit Center Hierarchy view and use the above created view as below,

SAP HANA, Calculation views

In Projection_1 we have to select the following columns and apply the filters mentioned below.

SAP HANA, Calculation views

There  are different groups in SAP like Cost Center, to identify the Profit Center group we have to filter SetClass=’0106‘

Filters used in Projection_1 for Profit Center =’0106’,ControllingArea and Group Node.

SAP HANA, Calculation views

Join1: Left Join SUBSET to SUBSETNAME and also SetClass to SetClass  to get Level1,Level2 and Level3 with descriptions(Nodes and Leaves).

SAP HANA, Calculation views

Join_2: Inner Join SubSet to SetName to get Level4 and Level4 Description.

The leaf node will either be a group node or Profit Center; Profit Center will always be a leaf node.

SAP HANA, Calculation views

Join_3: Left Join to get all the Level1,Level2,Level3 and Level4 with descriptions

SAP HANA, Calculation views

Proceed further for more levels depending on the requirement.

Create a calculated column to get all Profit Centers into one column.This calculated column will contain leaf node of each field and can be used to join the hierarchy with the transaction data.

SAP HANA, Calculation views

Final Semantics is

SAP HANA, Calculation views

Save and Activate the view.