Registration

Dear SAP Community Member,
In order to fully benefit from what the SAP Community has to offer, please register at:
http://scn.sap.com
Thank you,
The SAP Community team.
Skip to end of metadata
Go to start of metadata

SAP Online Documentation

Important Points to Know:

  1. 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.
  2. 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
  3. 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
  4. Intervals are not supported in CDS hierarchy so far. Please use a join to an additional view to resolve the intervals into single values.
  5. Temporal hierarchy join (THJ) is not supported in CDS hierarchy.
  6. Exception aggregation NHA is supported. NGA is not supported.   
  7. 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.
  8. 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.
  9. 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:

  1. 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 can only have one entry in the hierarchy directory view.
  2. 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. 
  3. 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

Use a Hierarchy in a CDS Query

  1. To hide the inner leaf of postable hierarchy nodes use annotation @AnalyticsDetails.query.hierarchySettings.hidePostedNodesValues

  2. 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

  3. To set default value for hierarchy parameter: use annotation @Consumption.defaultValue

  4. To set default value for hierarchy node variable: use annotation @Consumption.filter.defaultHierarchyNode or @Consumption.derivation

Examples

Time Hierarchy

See Note 2289865 → Configuration of Hierarchies for Time Characteristics (optional)

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)

    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)

    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

InfoArea hierarchy

 Blogs

Building hierarchies in CDS views

Hierarchies in CDS Views

 

 

 

  • No labels