Technical Aspect of Hierarchy in BW
Technical Aspect of Hierarchy in BW
BW
Applies to:
SAP BI 7.0 Consultants. For more information, visit the EDW homepage.
Summary
This Article gives detail level of understanding on Hierarchy from modeling and Technical Aspects.
Author: Vipin A
Company: Cognizant Technology Pvt. Ltd
Created on: 29th August 2011
Author Bio
Vipin A is a Senior BI Consultant in Cognizant Technology Pvt. Ltd. He has 6 years of experience in BW and
ABAP
SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BA - boc.sap.com | UAC - uac.sap.com
© 2011 SAP AG 1
Technical Aspect of Hierarchy
Table of Contents
Hierarchy Definition ............................................................................................................................................ 3
Hierarchy Structures ........................................................................................................................................... 4
Hierarchy Maintenance ....................................................................................................................................... 5
Hierarchy Activation ............................................................................................................................................ 6
Query Execution Details for Hierarchy ............................................................................................................... 6
Hierarchy Setting for Reporting Purpose ............................................................................................................ 8
NODE Attribute ................................................................................................................................................... 9
Hierarchy Version ............................................................................................................................................... 9
Intervals .............................................................................................................................................................. 9
Important Tables ............................................................................................................................................... 10
Important Temporary Hierarchy Tables for IDOC............................................................................................. 10
Important Packages .......................................................................................................................................... 11
Related Content ................................................................................................................................................ 15
Disclaimer and Liability Notice .......................................................................................................................... 16
SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BA - boc.sap.com | UAC - uac.sap.com
© 2011 SAP AG 2
Technical Aspect of Hierarchy
Hierarchy Definition
A hierarchy is a method of displaying a characteristic structured and grouped according to individual
evaluation criteria.
Example:
SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BA - boc.sap.com | UAC - uac.sap.com
© 2011 SAP AG 3
Technical Aspect of Hierarchy
Hierarchy Structures
A) Components of Hierarchy:
These are Top Of Hierarchy – They don’t have superior
Root
Nodes.
The uppermost node is the root.
Nodes
Precisely one other node is directly superior to each node
(except for the uppermost node).
Nodes that can be posted to refer to the hierarchy basic
characteristic.
Nodes that cannot be posted either text nodes or external
characteristic nodes.
Consist of characteristic values for the basic characteristic -
Leaves
have entries in the fact table.
All nodes on the same level of the hierarchy (nodes that are
Hierarchy Levels
the same distance away from the root) form a hierarchy level.
The root equals level 1.
Set of leaves that are described by its upper and lower
Intervals
boundaries.
Can be created if a node has more than one leaf.
B) Structure of Node:
Nodes that can be Posted Nodes that can not be Posted
All nodes that refer to the Nodes that cannot be posted do not
characteristic (hierarchy basic refer to the basic characteristic. They
characteristic) for which the are either text nodes that you can
hierarchy has been created, are include in the hierarchy or external
nodes that can be posted to. characteristic nodes.
Transaction data can only be Text nodes function purely as
dragged from the data target for headers, and they are there only to
nodes that can be posted to. improve the structure of your
Leaves are nodes that can be hierarchy. They are special
posted and that do not have any characteristic nodes for characteristic
lower-level nodes. 0HIER_NODE.
The leaves of a hierarchy are In addition, you can attach external
characteristic values or characteristic nodes to the hierarchy
characteristic value intervals (if basic characteristic. You can identify
intervals are allowed in the any nodes, including a set of leaves
hierarchy for the characteristic). with the characteristic value of any
characteristic (InfoObject).
SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BA - boc.sap.com | UAC - uac.sap.com
© 2011 SAP AG 4
Technical Aspect of Hierarchy
Hierarchy Maintenance
RSD1 -> <Characteristics Name> -> Hierarchy
Hierarchy Details
SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BA - boc.sap.com | UAC - uac.sap.com
© 2011 SAP AG 5
Technical Aspect of Hierarchy
Hierarchy Activation
The hierarchy is either loaded into BW, i.e. from a R/3 or a flat file, or created in RSD1. The
hierarchy has status inactive and is filed in table RSHIEDIR as M (modified) version (field
OBJVERS).
Activation creates in the corresponding hierarchy tables an A version from the M version
All nodes are checked for permitted characters.
For those nodes that do not yet have an SID, an SID is created and stored in the corresponding
SID table /BI*/S<IOBJNM>.
Inclusion table /BI*/I<IOBJNM>, SID node table /BI*/K<IOBJNM>,and the RSRHIEDIR_OLAP
table are updated, or new entries are created
The basis for creating the inclusion table is FM RSSH_HIERARCHY_READ, which delivers the
hierarchy nodes for the current key date (the key date is only relevant for time-dependent
hierarchies), where existing link nodes are expanded. This FM can be called up for each
hierarchy in test mode.
With hierarchies whose structures are time-dependent, the activation occurs for the SY-DATE
key date. By calling with a key date in the query, an active version is created for this key date.
Solutions:
There is no error – it could be correct. If the transaction data does not fit to the data in the
hierarchy (for example, Plant 1000 is not included in the hierarchy), then this value is displayed
under “not assigned”.
The hierarchy data is not mapped to the correct Infoobject (for example, the 0Plant is loaded to
ZPlant). The result is a valid hierarchy that doesn’t include any ZPlant nodes. Therefore, the
ZPlant values are displayed under “not assigned”.
Values in the hierarchy seem to adjust to the transaction data. The external representation
adjusts to each other, but the internal representation differs. (For example, an ALPHA problem:
external representation 1 but internal 1 and 0000001 are not equal). Check SID table and
internal node name in the hierarchy maintenance.
SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BA - boc.sap.com | UAC - uac.sap.com
© 2011 SAP AG 6
Technical Aspect of Hierarchy
SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BA - boc.sap.com | UAC - uac.sap.com
© 2011 SAP AG 7
Technical Aspect of Hierarchy
SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BA - boc.sap.com | UAC - uac.sap.com
© 2011 SAP AG 8
Technical Aspect of Hierarchy
NODE Attribute
Time-Dependent Hierarchies:
Use:
In the Infoobject characteristic maintenance you determine whether or not a hierarchy may be time-
dependent. You define either that the entire hierarchy should be time-dependent or that the hierarchy
structure (each individual node relationship) should be time-dependent.
If you only need the hierarchy each month, you should create the entire hierarchy as time-dependent.
However, if you only need the current view on the hierarchy, you should not create it as time-dependent. Of
course you can activate it as often as you like.
Hierarchy Version
Requirements
You have specified in the Info object maintenance, that the corresponding hierarchy characteristic is
hierarchy version-dependent.
Use
Characteristic hierarchies can be used in different hierarchy versions
Functions
You can create different hierarchy versions under the same technical name. You then compare the different
hierarchy versions in reporting.
Intervals
A node can be defined as an interval (INTERVFL in /BI*/H<IOBJNM>)
The interval value always refers to the hierarchy basic characteristic
The from-value is saved in the LEAFFROM field, and the to-value is saved in the LEAFTO field from the
/BI*/J<IOBJNM> table
SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BA - boc.sap.com | UAC - uac.sap.com
© 2011 SAP AG 9
Technical Aspect of Hierarchy
Important Tables
1) RSHIEDIR
Table that contains the header for a hierarchy.
2) RSHIEDIRT
It’s just the text table for the table rshiedir with an index on HieID and Objvers to avoid deadlocks if the texts
for more than one hierarchy are deleted parallel.
3) RSHIELVT
Level table to store the texts for the levels. This table is only filled if texts exist otherwise the default texts for
the levels are used.
4) RSMHIERNODE
The textnodes are saved in this table.
5) RSTHIERNODE
This table contains the text of the text nodes of a hierarchy for each language. With the index on hieid and
objvers the data for one hierarchy can be accessed fast.
6) H Table /BI*/H<IOBJNM>
In this table the entire structure of the hierarchy is stored. The key for each node is the nodeID.
7) J Table /BI*/J<IOBJNM>
In this table the intervals are stored for the node with the corresponding nodeid in the H-table.
SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BA - boc.sap.com | UAC - uac.sap.com
© 2011 SAP AG 10
Technical Aspect of Hierarchy
Important Packages
RSSH
Important Transactions
A) RSH1
Main transaction to start the maintenance for a special hierarchy or to get an overview over the existing
hierarchies.
B) RHIERSIM
Start the simulation for IDOC hierarchies for an Oltp or BW-system that has an RFC connection to this BW
system.
Classes
A) CL_RSSH_HIERARCHY_BASE
This is the most important and central class for the BW hierarchies!
CL_RSSH_HIERARCHY_BASE is the Base class that is used for the most hierarchy operations. An instance
represents one hierarchy. On this hierarchy different operations can take place like checking, saving, subtree
insert, create new nodes, delete nodes or subtrees etc. For every action that changes the hierarchy on the
database this class is used.
SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BA - boc.sap.com | UAC - uac.sap.com
© 2011 SAP AG 11
Technical Aspect of Hierarchy
B) CL_RSSH_HIERARCHY_FUNC
This class is a collection of static methods that allow external access to the hierarchies in the Warehouse
Management.
Important Methods:
CHECK
This static method can be used to check a hierarchy. The whole hierarchy structure can be passed to the
method or only the hieid is passed to the method, then the hierarchy is loaded from the database using the
hieid. In any case an instance of the class cl_rssh_hierarchy_base is created. Then the method check of the
instance is called. if an error log exists it is passed back to the caller or in dialog mode it is displayed in an
amodal window.
CHECK_AND_ACTIVATE
Calls simply Function RSHIER_HIER_CHECK_AND_ACTIVATE
COPY
This method copies a hierarchy. The header data for the target hierarchy could be given by an import
parameter or is inserted in a dialog that depends on the import paramter I_with_dialog. To copy the hierarchy
two instances of the class cl_rssh_hierarchy_base are used. Enqueues and authority checks for both
hierarchies source and target are done.
GET
External access to get all tables of a hierarchy or a subtree or only the hierarchy header that depends of the
filling of the import parameters. The hierarchy can be selected by the hieID or the semantical key (unique
index of rshiedir).
NDI_GET
This method is the basis for the RSNDI_SHIE-RFC-functions that provide hierarchy data. It calls the GET
method and provides the node attributes of the hierarchy in a separate table so that the data is provided in a
fixed table format that can be used for RFC.
NDI_UPDATE
Method that is executed by the RSNDI - RFC – Framework to update hierarchy data. It just prepares the
parameter in that way that the real UPDATE method can be called.
UPDATE
This is the main Method that is called during the Upload of a hierarchy and uses an instance of class
cl_rssh_hierarchy_base to save a hierarchy or subtree in the database.
SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BA - boc.sap.com | UAC - uac.sap.com
© 2011 SAP AG 12
Technical Aspect of Hierarchy
C) CL_RSSH_HIERARCHY_SEL_ALV
Class that handles the main behavior of transaction RSH1 (Entry for hierarchy maintenance).
P_R_CUSTOM_CONTAINER
Contains the instance of the custom container for the ALV
P_T_HIEDIRTXT
Contains the hierarchy headers with texts
P_IOBJNM
Contains the hierarchy basis characteristic that is used to filter the data
D) CL_RSSH_HIERDATA
This class is used for the data transfer of hierarchy data / subtrees for drag & drop.
E) CL_RSSH_HIERMAINTAIN
This is the Main class for the hierarchy maintenance that is managing the Main dynpro that means it
manages and creates the control containers for the Hierarchy itself and for the main toolbar and it reacts on
fcodes that are raised from the main toolbar or the main dynpro.
Important Attributes
P_R_HIERMTF Type Ref To CL_RSSH_HIERMAINTAIN_FRONT
Instance of the special hierarchy instance inclusive representation in a tree control
P_R_MAINCONTAINER Type Ref To CL_GUI_CUSTOM_CONTAINER
Main custom container of dynpro 100
P_R_HIERMT Type Ref To CL_RSSH_HIERMAINTAIN
Instance of the hierarchy maintenance framework
P_R_TOOLBAR Type Ref To CL_GUI_TOOLBAR
Instance of the main Toolbar
SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BA - boc.sap.com | UAC - uac.sap.com
© 2011 SAP AG 13
Technical Aspect of Hierarchy
F) CL_RSSH_HIERMAINTAIN_BASE .
This class is a Subclass of CL_RSSH_HIERARCHY_BASE.
This class extends the hierarchy basis class with methods that are needed if a hierarchy is changed
manually. E.g. Insertion of single nodes, display a single node, move a subtree etc.
Important Attributes
P_CHANGEMODE Type RS_BOOL
Flag to check if the hierarchy can be changed (change modus)
P_INSERTASNEXT Type RS_BOOL
Behavior if a node is inserted as the next or child node of the node where the insert action is performed on.
P_T_FIELDINDEXNODE Type RSSH_T_FIELDINDEX
Index table where relation between columns of the model tree and fields of the H-table is stored.
G) CL_RSSH_HIERMAINTAIN_FRONT
This is the Main class for the hierarchy maintenance that handles the representation and user interaction for
a single hierarchy.
H) CL_RSSH_HIERMAINTAIN_LEVEL
This class displays the texts of the level of a hierarchy instance in a docking container for a hierarchy that is
displayed in the hierarchy maintenance. The level texts can be maintained in up to the actual maximal level.
When the hierarchy is stored the level texts are stored as well. To read the level texts the function
RSSH_LEVEL_READ can be used that provides the texts for a hierarchy.
I) CL_RSSH_MESSAGE_HANDLER
This class can be used to be able to use error messages though you are using a control (e.g. ALV) that
raises error messages while not in PAI.
J) CL_RSSH_SERVICE
This class contains hierarchy services that can be used from external programs. In the moment only the
method FILL_CHILD_AND_NEXT is available. If you pass a hierarchy structure to the method the
corresponding Child- and next-Ids are created and stored in the fields’ childID and nextID of that structure.
K) CL_RSSH_SHOW_LOG
With the statically method SHOW_MESSAGES_WRITE_LOG you can pass a message table to the class
that is shown in an a modal window (cl_gui_dialogbox_container). You can close the a modal window using
the method DELETE_WINDOW otherwise the window will pop up again if the same dynpro is called in the
same internal modus.
L) CL_RSSH_TIMEHIERARCHY
This class is used from the time hierarchy framework (Transaction RSRHIERARCHYVIRT) to save the
header data and level table of a time hierarchy in the header table rshiedir. This class uses the normal
hierarchy framework (cl_rssh_hierarchy_base) to store the data.
Important Attributes
P_R_HIER Type Ref To CL_RSSH_HIERARCHY_BASE
The hierarchy basis instance that is used to access the hierarchy framework and to store the header data.
SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BA - boc.sap.com | UAC - uac.sap.com
© 2011 SAP AG 14
Technical Aspect of Hierarchy
Related Content
https://www.sdn.sap.com/irj/sdn/index
For more information, visit the EDW homepage
SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BA - boc.sap.com | UAC - uac.sap.com
© 2011 SAP AG 15
Technical Aspect of Hierarchy
SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BA - boc.sap.com | UAC - uac.sap.com
© 2011 SAP AG 16