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.
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.
- 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 time dependent 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
- 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)
See Note 2289865 → Configuration of Hierarchies for Time Characteristics (optional)
Hierarchy Handling in ODATA Service
- 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)
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)
- 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)
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
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
- 2584360 ABAP CDS: Missing texts in ODP list