I have created a Fiori Elements List Report and set the table type to TreeTable. The table is displayed as a TreeTable but every entity is displayed as a root entity in the table and the following error is in the log: "Neither navigation paths parameters, nor (complete/valid) tree hierarchy annotations where provided to the TreeBinding.".
The OData service is based on the following projection view:
@Metadata.allowExtensions: true
@ObjectModel.representativeKey: 'Element'
@ObjectModel.dataCategory: #HIERARCHY
@Hierarchy.parentChild: [
{ recurse.child: ['Element'],
recurse.parent: ['ParentElement'],
recurseBy: '_ParentElement',
multipleParents: true,
siblingsOrder: [{by: 'Element', direction: #DESC}],
orphanedNode.handling: #ROOT_NODES
}
]
define root view entity ZC_Element
as projection on ZI_Element
{
@ObjectModel.foreignKey.association: '_Element'
key Element,
ParentElement,
ChildNode,
ParentNode,
HierarchyLevel,
HierarchyTreeSize,
HierarchyRank,
HierarchyParentRank,
HierarchyIsOrphan,
HierarchyIsCycle,
HierarchyDrillState,
CreatedBy,
CreatedAt,
LastChangedBy,
LastChangedAt,
_Element,
_ParentElement
}
The hierarchy, which is at the basis of the views, is as followed:
define hierarchy ZHI_ElementHierarchy
as parent child hierarchy(
source ZHI_ElementRelation
child to parent association _ParentElement
start where
ParentElement is initial
siblings order by
Element
multiple parents allowed
orphans root
)
{
@ObjectModel.foreignKey.association: '_VirtualDirectory'
key Element,
_Element,
ParentElement,
_ParentElement,
$node.parent_id as ParentNode,
$node.node_id as ChildNode,
$node.hierarchy_is_orphan as HierarchyIsOrphan,
$node.hierarchy_level as HierarchyLevel,
$node.hierarchy_rank as HierarchyRank,
$node.hierarchy_parent_rank as HierarchyParentRank,
$node.hierarchy_tree_size as HierarchyTreeSize,
$node.hierarchy_is_cycle as HierarchyIsCycle,
CreatedBy,
CreatedAt,
LastChangedBy,
LastChangedAt
}
The metadata file of the OData service does not contain any hierarchy annotations. I have also attempted to add the following annotations manually to the annotations.xml file but this does not have any effect either:
<Annotations Target="cds_zsd_elements.ElementType">
<Annotation Term="UI.LineItem">
<Collection>
<Record Type="UI.DataField">
<PropertyValue Property="Value" Path="Element"/>
<PropertyValue Property="sap:hierarchy-node-for" Path="Element"/>
</Record>
<Record Type="UI.DataField">
<PropertyValue Property="Value" Path="ParentElement"/>
<PropertyValue Property="sap:hierarchy-parent-node-for" Path="Element"/>
</Record>
<Record Type="UI.DataField">
<PropertyValue Property="Value" Path="HierarchyLevel"/>
<PropertyValue Property="sap:hierarchy-level-for" Path="Element"/>
</Record>
<Record Type="UI.DataField">
<PropertyValue Property="Value" Path="HierarchyDrillState"/>
<PropertyValue Property="sap:hierarchy-drill-state-for" Path="Element"/>
</Record>
</Collection>
</Annotation>
</Annotations>
I have used the projection view in an ABAP program with ALV TreeTable as well and the output is displayed correctly, so the hierarchy and data seems to be correct. What can I do to get the hierarchy annotations correct?