SAP Online Documentation
Important Points to Know:
- A CDS Hierarchy (regarding BW standard hierachies see Characteristic Hierarchies) is defined regarding an view of data catagory DIMENSION (BW InfoObject). So far, such a hierarchy is only supported by the Analytic Engine. Therefore, although the hierarchy definition is always available in the metadata, only within a CDS query ( @Analytics.query:true) it is interpreted.
- It is allowed to assign one leaf to multiple parents(duplicate leaves) but CDS queries don't support link nodes. Regarding difference of link and duplicate nodes see Hierarchies:Link Nodes
- In a CDS query, it is not supported to define a hierarchy node parameter. Because hierarchies are not part of the core CDS, there is no parameter of hierarchy node type. Hierarchy is defined by using annotations. Therefore, to enter a hierarchy node before starting a query, please use @Consumption.filter.selectiontype: #HIERARCHY_NODE
- Intervals are not supported in CDS hierarchy so far. Please use a join to an additional view to resolve the intervals into single values.
- Temporal hierarchy join (THJ) is not supported in CDS hierarchy.
- Exception aggregation NHA is supported. NGA is not supported.
- Presentation/Display hierarchy with 'Position of Child Nodes' as above, is not supported in a CDS query so far. Please use a BW query (based on a corresponding CDS Cube) instead if this feature is needed.
- CDS hierarchy can only be either hierarchy header (directory) time dependent, or hierarchy structure time dependent. It is not supported if both hierarchy header and structure are time dependent.
- Hide inner node in F4 help for a CDS hierarchy node variable on variable screen is not supported yet.
- As explained in Hierarchies: Troubleshooting Reports, transaction RSRT(Query Monitor) offers the possibility to delete/refresh the buffer for all hierarchies used in a certain query. This is also valid for CDS hierarchies. However, by default CDS hierarchies are not buffered on BW side. They are only buffered if the CDS hierarchy uses a hierarchy directory and in the hierarchy directory view you have a timestamp field for the last hierarchy update which uses annotation @Semantics.systemDate.lastChangedAt: true.
Defining a Hierarchy
To define a CDS Hierarchy:
- Define the key fields that specify a hierarchy. They are associated with a hierarchy directory. So that different hierarchies can be chosen in F4 on hierarchy. Each hierarchy ( the (hierarchyname, validto) combination for a time dependent hierarchy) can only have one entry in the hierarchy directory view.
- Define fields for parent-child relation:
Parent and child should have same number of fields and parent-structure fits to the child-structure.
The child-fields have to be key fields.
The relation between parent-child is given by @Hierarchy.parentChild.recurse(by) annotation.
For root nodes, the parent fields have to be initial (that is, the field needs to be blank).
It is not necessary that there is any semantic in the fields. - Define semantic fields to describe each node or leaf. The semantic fields should have a foreignKey association and the order of the associations is relevant.
Examples
- A very simple hierarchy with a fixed hierarchy name: Defined with @Hierarchy.parentChild.name
- A simple hierarchy with hierarchy directory
- CDS Hierarchy with Hierarchy Directory and External(Text) and Postable Hierarchy Nodes
- CDS Hierarchy with Duplicate Nodes
- A header time dependent CDS hierarchy
- A Structure time dependent CDS hierarchy
Use a Hierarchy in a CDS Query
To hide the inner leaf of postable hierarchy nodes use annotation @AnalyticsDetails.query.hierarchySettings.hidePostedNodesValues
To suppress 'not assigned node': use annotation @Consumption.filter and @Consumption.derivation to derive the root node of the hierarchy and set a filter on this node
To set default value for hierarchy parameter: use annotation @Consumption.defaultValue
To set default value for hierarchy node variable: use annotation @Consumption.filter.defaultHierarchyNode or @Consumption.derivation
Examples
- Hide inner node of postable hierarchy nodes
- Dynamically activate hierarchy in a CDS query (and use @Consumption.defaultValue to set default value for hierarchy parameter)
- Set a hierarchy node filter in a CDS query (the usage of @Consumption.filter.defaultHierarchyNode, and suppress 'not assign node' with it)
- Suppress 'not assigned' node in a CDS query with a dynamic hierarchy active (the usage of @Consumption.derivation to derive a dynamic hierarchy root node)
Time Hierarchy
See Note 2289865 → Configuration of Hierarchies for Time Characteristics (optional)
When used in SAC:
It is needed to have the full set of Time-Dimensions (that are part of the Virtual Time Hierarchy) to be part of Query definition, either as Navigation Attributes or as Free-Dimensions (Free Characteristic section of the Query Designer). For example, to be able to use Hierarchy 0YEA_MON_DAY, 0CALYEAR, 0CALMONTH, and 0CALDAY are needed to be part of the Query definition.
See Note 2895891 - BW-Live Time-Series Chart drill levels are not available Part 1
Hierarchy Handling in ODATA Service
ODATA Query: Hierarchy Handling
SAP Notes
- 2528306 Using Hierarchy in a CDS query
- 2381699 BW Query generated based on CDS: support for $session (e.g. $session.system_date) - plus various enhancements ( to use @AnalyticsDetails.query.hierarchySettings.hidePostedNodesValues etc)
- 3142924 CDS Hierarchy defined with @Hierarchy.parentChild.name doesn't work in a CDS Query
wrong data related to 0K table: - 2410674 CDS: Wrong Data in Query with Hierarchy
- 2476086 Wrong Data in Query with Hierarchy (CDS)
- 2635307 Wrong data in query with hierarchy (CDS only)
wrong data: - 2770517 Different FEMS-N conditions on the same characteristic are mixedly handled as key and sid based when a hierarchy restriction is in place
- 2805070 750SP16: Query based on CDS Views with hierarchy Association doesn't work (Hierarchy node selection gets wrong data if the field associate to a master data view with different length. After the correction, hierarchy is not pushed down any more and handled in ABAP)
- 3156568 Memory consumption of local NODESID buffer → after this note, delete the hierarchy buffer to get the latest hierarchy
Time dependent hierarchy: 2643436 750SP13: Point in Time ignored in case of Query based on CDS views with Hierarchies
2624812 750SP12: Incorrect Hierarchy time dependent nodes are returned
Performance:2789013-750SP16: Performance problem during determination of Hierarchy CDS Header
- 2728518-752SP4:Check validity of metadata buffer doesn't work in case of Inline Hierarchy CDS view
- 2742363-Performance Optimization: Accesss to hierarchy directory
- 2892479-Performance Improvement for Time Dependent CDS Hierarchy Header Text Association
InfoArea hierarchy - 2584360 ABAP CDS: Missing texts in ODP list
- 3025422 Open Dialogs: Slow Performance Expanding Info Provider Tree
Hiearchy/Node Variables - 2771756 CDS - BW query generation: Misleading message
Set hierarchy node filter error in WebDynpro app - 3071395 Error Message after trying to select a leaf node in hierarchical value help
Hierarchy F4: - 3071395 Error Message after trying to select a leaf node in hierarchical value help
- 3143464 CDS Hierarchy defined with multiple key Header with Text Association displays no Text in F4
- 3135668 F4 Help for CDS Hierarchy with multiple Keys has no Text
- 3148012 F4 Help for CDS Hierarchy with multiple Keys has no Text (2)
Blogs
Building hierarchies in CDS views