Professional Documents
Culture Documents
INTRODUCTION
STANDARD HIERARCHY
Definition:
Standard hierarchy is a tree hierarchy which is used to organize business processes of a controlling area.
The highest node of a standard hierarchy is normally the first business process group. The groups created
thereafter make of the remaining nodes of the standard hierarchy.
The standard hierarchy is assigned directly to the controlling area and has itself a set of business process
groups assigned to it. This ensures that all business processes belonging to a controlling area are grouped
together.
Example:
Sales Hierarchy
Root
Nodes
Leaves
Hierarchy Levels
Intervals
The details of the above cost center hierarchy are provided below:
CHARACTERISTICS
DETAILS
Controlling Area
0001
Root
C1000
Nodes
Leaves
Hierarchy Levels
Group Nodes
TYPE
CA_HIERARCHY
Scripted
True
Input Parameters:
1. SNO.
NAME
DATA TYPE
SIZE
COMMENTS
1. 1.
ControllingArea
NVARCHAR
12
to input controlling
area of the
hierarchy
1. 2.
Group_Root_Node
NVARCHAR
24
1. SNO.
NAME
DATA TYPE
SIZE
COMMENTS
1. 1.
MANDT
NVARCHAR
Client
1. 2.
PARENT
NVARCHAR
24
1. 3.
GROUP_NODE
NVARCHAR
24
1. 4.
COST_CENTER
NVARCHAR
24
1. 5.
LEVEL
INTEGER
Output Columns:
CONTROLLING_AREA
NVARCHAR
Hierarchy controlling
area (it will be
same as the input
controlling area)
Conditions:
1. S. NO.
CONDITON
DETAILS
1. 1.
SETCLASS = 0101
Source Code:
/********* Begin Procedure Script ************/
/*In case Group_Root_Node is empty, retrieve only leaf(Cost center) node from SETLEAF table*/
if :Group_Root_Node = '' then
LT_CC_TMP = SELECT MANDT AS MANDT, NULL AS PARENT, NULL AS GROUP_NODE, VALOPTION
AS VALOPTION, VALFROM as VALFROM, VALTO as VALTO, 1 AS LEVEL, :ControllingArea AS
CONTROLLING_AREA
FROM SETLEAF
WHERE SETCLASS = '0101' and SUBCLASS = :ControllingArea;
var_out = SELECT MANDT, PARENT, GROUP_NODE, VALFROM AS COST_CENTER, LEVEL,
CONTROLLING_AREA
FROM :LT_CC_TMP;
LT_CC_TMP2 = SELECT CC.MANDT AS MANDT, NULL AS PARENT, CC.GROUP_NODE AS
GROUP_NODE, CSKS.KOSTL AS COST_CENTER, CC.LEVEL AS LEVEL, :ControllingArea AS
CONTROLLING_AREA
FROM :LT_CC_TMP as CC inner join CSKS as CSKS ON (CSKS.MANDT = CC.MANDT and CSKS.KOSTL
>= CC.VALFROM and CSKS.KOSTL <= CC.VALTO)
WHERE CSKS.KOKRS = :ControllingArea;
var_out = SELECT MANDT, PARENT, GROUP_NODE, COST_CENTER, LEVEL, CONTROLLING_AREA
from :var_out
UNION
SELECT MANDT, PARENT, GROUP_NODE, COST_CENTER, LEVEL, CONTROLLING_AREA from
:LT_CC_TMP2;
/*Retrieve all hierarchy groups and the cost center from both SETNODE and SETLEAF, incase
Group_Root_Node is not empty*/
else
LT_ROOT = SELECT DISTINCT MANDT AS MANDT, NULL AS PARENT, SETNAME AS GROUP_NODE,
NULL AS COST_CENTER, 1 AS LEVEL, :ControllingArea AS CONTROLLING_AREA
FROM SETNODE
WHERE SETCLASS = '0101' and SUBCLASS = :ControllingArea and SETNAME = :Group_Root_Node;
/*inacase for a group node, there is no subgroup, then it will not be in SETNODE, but only in SETLEAF*/
LT_ROOT2 = SELECT DISTINCT MANDT AS MANDT, NULL AS PARENT, SETNAME AS GROUP_NODE,
NULL AS COST_CENTER, 1 AS LEVEL, :ControllingArea AS CONTROLLING_AREA
FROM SETLEAF
WHERE SETCLASS = '0101' and SUBCLASS = :ControllingArea and SETNAME = :Group_Root_Node;
LT_HIERARCHY = SELECT MANDT, PARENT, GROUP_NODE, COST_CENTER, LEVEL,
CONTROLLING_AREA from :LT_ROOT
UNION
SELECT MANDT, PARENT, GROUP_NODE, COST_CENTER, LEVEL, CONTROLLING_AREA from
:LT_ROOT2;
while 1 = 1 do
LT_HIERARCHY_TMP = SELECT part.MANDT AS MANDT, part.SETNAME AS PARENT,
part.SUBSETNAME AS GROUP_NODE, NULL AS COST_CENTER, :LEV + 1 AS LEVEL, :ControllingArea
AS CONTROLLING_AREA
FROM :LT_HIERARCHY as main inner join SETNODE as part ON (part.MANDT = main.MANDT and
main.GROUP_NODE = part.SETNAME)
WHERE part.SETCLASS = '0101' and part.SUBCLASS = :ControllingArea and main.LEVEL = :LEV;
SELECT COUNT(*) INTO NUM FROM :LT_HIERARCHY_TMP;
if :NUM = 0 then
break;
end if;
LT_HIERARCHY = SELECT MANDT, PARENT, GROUP_NODE, COST_CENTER, LEVEL,
CONTROLLING_AREA from :LT_HIERARCHY
UNION
SELECT MANDT, PARENT, GROUP_NODE, COST_CENTER, LEVEL, CONTROLLING_AREA from
:LT_HIERARCHY_TMP;
LEV := :LEV + 1;
end while;
LT_CC_TMP = SELECT CC.MANDT AS MANDT, CC.SETNAME AS PARENT, NULL AS GROUP_NODE,
CC.VALOPTION AS VALOPTION, CC.VALFROM as VALFROM, CC.VALTO as VALTO, CC_gr.LEVEL + 1
AS LEVEL, :ControllingArea AS CONTROLLING_AREA
FROM :LT_HIERARCHY as CC_gr inner join SETLEAF as CC ON (CC.MANDT = CC_gr.MANDT and
CC_gr.GROUP_NODE = CC.SETNAME)
WHERE CC.SETCLASS = '0101' and CC.SUBCLASS = :ControllingArea;
LT_CC = SELECT MANDT, PARENT, GROUP_NODE, VALFROM AS COST_CENTER, LEVEL,
CONTROLLING_AREA
FROM :LT_CC_TMP;
The following output of the above scripted view, for the given cost center hierarchy:
The above shown is the parent child relation of the hierarchy with cost center.
STEP 2: JOIN THE SCRIPTED HIERARCHY VIEW WITH THE TEXT TABLES TO GET DESCRIPTION
TEXT
In order to get the description of a hierarchy, we need to join the scripted view (CA_HIERARCHY), with the two
text tables i.e. SETHEADERT for group nodes and specific text tables for the module like CSKT for cost center,
CEPCT for profit center text, etc. will be used. As in this case, we are implementing cost center hierarchy, so
CSKT table will be used.
The following are the details of the calculation view:
NAME
TYPE
DATA CATEGORY
CA_HIERARCHY_DESCRIPTION
Graphical
Dimension
Required Tables/Views:
1. SNO.
NAME
VIEW/TABLE
COMMENTS
1. 1.
CA_HIERARCHY
VIEW
1. 2.
SETHEADERT
TABLE
Table containing
description text
for groups (i.e.
COSTCENTERGROUP
in this view)
1. 3.
CSKT
TABLE
Table containing
description text for cost
center.
Input Parameters:
1. SNO.
NAME
DATA TYPE
SIZE
COMMENTS
1. 1.
ControllingArea
NVARCHAR
12
to input controlling
area of the
hierarchy (map
with that of the
scripted view,
CA_HIERARCHY)
1. 2.
Group_Root_Node
NVARCHAR
24
to input the
group (root) node
(map with that
of scripted view,
CA_HIERARCHY)
1. SNO.
NAME
DATA TYPE
SIZE
COMMENTS
1. 1.
MANDT
NVARCHAR
Client
Output Columns:
1. 2.
PARENT
NVARCHAR
24
1. 3.
LEVEL
INTEGER
1. 4.
CONTROLLING_AREA
NVARCHAR
Hierarchy controlling
area (it will be
same as the input
controlling area)
1. 5.
Level
NVARCHAR
24
Calculated column
for level
1. 6.
Level_Description
NVARCHAR
50
Calculated Column
for level text
Join details:
1. SNO.
LEFT
TABLE
1. 7.
1. 8.
LEFT
FIELDS
RIGHT
TABLE
DESCRIPTION
FIELDS
CA_HIERARCHY
MANDT,
SETHEADERT
MANDT,
GROUP_NODE
SETNAME
TEXT
Join_1
DESCRIPT
JOIN_1
TEXT
Join_2
LTEXT
MANDT,
CSKT
COST_CENTER,
CONTROLLING_AREA
RIGHT
FIELDS
MANDT,
KOSTL,
KOKRS
Filter details:
1. SNO.
FILTER FIELDS
TABLE
FILTER
CONDITION
COMMENTS
1. 1.
SETCLASS
SETHEADERT
SETCLASS = 0101
SETCLASS specific
to cost center
1. 2.
SUBCLASS
SETHEADERT
SUBCLASS = 0001
SUBCLASS specific
to controlling area
As explained earlier, that the leaf node will either be a group node or cost center; or cost center will always be
a leaf node. So, here these two columns will be combined into one, creating a calculated column, and doing the
same for description.
Following are the two calculated columns:
1. SNO.
NAME
DATA TYPE
SIZE
FORMULA
1. 1.
Level
NVARCHAR
50
if(isnull("GROUP_NODE"),"COST
1. 2.
Level_Description
NVARCHAR
50
if(isnull("DESCRIPT"),"LTEXT","D
Join_2
OUTPUT:
Provide the values to the input parameters:
The final output of this view:
TYPE
DATA CATEGORY
CA_HIERARCHY_LEVEL_FLATTENGraphical
Dimension
Required Tables/Views:
1. SNO.
NAME
1. 1.
CA_HIERARCHY_DESCRIPTION
VIEW
VIEW/TABLE
COMMENTS
Scripted hierarchy view
Input Parameters:
1. SNO.
NAME
DATA TYPE
SIZE
COMMENTS
1. 1.
ControllingArea
NVARCHAR
12
to input controlling
area of the
hierarchy (map
with that of
CA_HIERARCHY_DESCRIPTION
view)
1. 2.
Group_Root_Node
NVARCHAR
24
to input the
group (root) node
(map with that of
CA_HIERARCHY_DESCRIPTION
view)
1. SNO.
NAME
DATA TYPE
SIZE
COMMENTS
1. 1.
MANDT
NVARCHAR
Client
1. 2.
CONTROLLING_AREA
NVARCHAR
Hierarchy controlling
area (it will be
Output Columns:
LEVEL1
NVARCHAR
24
1. 4.
LEVEL1_DESCRIPTION
NVARCHAR
50
1. 5.
LEVEL2
NVARCHAR
24
1. 6.
LEVEL2_DESCRIPTION
NVARCHAR
50
1. 7.
LEVEL3
NVARCHAR
24
1. 8.
LEVEL3_DESCRIPTION
NVARCHAR
50
1. 9.
LEVEL4
NVARCHAR
24
1. 10.
LEVEL4_DESCRIPTION
NVARCHAR
50
1. 11.
JOIN_FIELD
50
Calculated column
to create a join
field (to join this
NVARCHAR
hierarchy with
transaction tables)
Note: The maximum level here is 4, so the flattening here will be done till level 4. If the hierarchy goes beyond
level 4, then further flattening will be required.
Join details:
1. SNO.
1. 1.
CA_HIERARCHY_DESCRIPTION
MANDT,
CA_HIERARCHY_DESCRIPTION
MANDT,
Left Outer
(LEVEL = 1) LEVEL
(LEVEL = 2)
PARENT
Join_1
1. 2.
CA_HIERARCHY_DESCRIPTION
MANDT,
CA_HIERARCHY_DESCRIPTION
MANDT,
Left Outer
(LEVEL = 2) LEVEL
(LEVEL = 3)
PARENT
Join_2
1. 3.
CA_HIERARCHY_DESCRIPTION
MANDT,
CA_HIERARCHY_DESCRIPTION
MANDT,
Left Outer
(LEVEL = 3) LEVEL
(LEVEL = 4)
PARENT
Join_3
RIGHT
TABLE
RIGHT
FIELDS
JOIN TYPE
JOIN NAME
Filter details:
1. SNO.
FILTER FIELDS
TABLE/VIEWS
1. 1.
LEVEL
CA_HIERARCHY_DESCRIPTION
LEVEL = 1
This is to get
level1 node and
description
1. 2.
LEVEL
CA_HIERARCHY_DESCRIPTION
LEVEL = 2
This is to get
level2 node and
description
1. 3.
LEVEL
CA_HIERARCHY_DESCRIPTION
LEVEL = 3
This is to get
level3 node and
description
1. 4.
LEVEL
CA_HIERARCHY_DESCRIPTION
LEVEL = 4
This is to get
level4 node and
description
1. SNO.
NAME
DATA TYPE
SIZE
FORMULA
1. 1.
JOIN_FIELD
NVARCHAR
24
if(isnull("LEVEL4"),if(isnull("LEV
"LEVEL2"),
"LEVEL3"),"LEVEL4")
FILTER
CONDITION
COMMENTS
Calculated columns:
OUTPUT:
Provide the values to the input parameters:
The final output of this view: