on 2024 Jul 15 5:09 AM
Hi, Experts!
I have a parent-child data model and need to calculate totals and subtotals in a tree table through fiori elements, but the defaulAggregation:#SUM does not work (Exactly like this question https://community.sap.com/t5/technology-q-a/how-to-calculate-totals-and-subtotals-in-fiori-elements-... posted few years ago)
Here is my tree table as of now:
For the tree table be displayed like this, I used the setUseGroupMode(true) method via custom extensions.
Here is the metadata generated by the backend (s/4hana op 2023) for the main entityType. Just note the aggregation annotations like dimension and measure.
<EntityType Name="ZFI_C_HIER_NODESResult" sap:semantics="aggregate" sap:label="Consumption View for Hier Nodes" sap:content-version="1">
<Key>
<PropertyRef Name="ID"/>
</Key>
<Property Name="ID" Type="Edm.String" Nullable="false" sap:sortable="false" sap:filterable="false"/>
<Property Name="NodeId" Type="Edm.String" MaxLength="20" sap:aggregation-role="dimension" sap:hierarchy-node-for="NodeId" sap:text="description"/>
<Property Name="Versn" Type="Edm.String" MaxLength="4" sap:aggregation-role="dimension" sap:display-format="UpperCase" sap:label="FS Version" sap:quickinfo="Financial Statement Version"/>
<Property Name="FSItem" Type="Edm.String" MaxLength="10" sap:aggregation-role="dimension" sap:display-format="UpperCase" sap:label="FS Item" sap:quickinfo="Financial Statement Item"/>
<Property Name="ParentNodeId" Type="Edm.String" MaxLength="20" sap:aggregation-role="dimension" sap:hierarchy-parent-node-for="ParentNodeId"/>
<Property Name="NodeLevel" Type="Edm.String" MaxLength="12" sap:aggregation-role="dimension" sap:hierarchy-level-for="NodeLevel"/>
<Property Name="Account" Type="Edm.String" MaxLength="10" sap:aggregation-role="dimension" sap:display-format="UpperCase" sap:label="Account From" sap:quickinfo="Account Interval Lower Limit"/>
<Property Name="ChartOfAccounts" Type="Edm.String" MaxLength="4" sap:aggregation-role="dimension" sap:display-format="UpperCase" sap:label="Chart of Accounts"/>
<Property Name="description" Type="Edm.String" MaxLength="45" sap:label="Text" sap:quickinfo="Financial Statement Item Text"/>
<Property Name="DrillState" Type="Edm.String" MaxLength="8" sap:aggregation-role="dimension" sap:hierarchy-drill-state-for="DrillState"/>
<Property Name="ProfitCenter" Type="Edm.String" MaxLength="10" sap:aggregation-role="dimension" sap:display-format="UpperCase" sap:label="Profit Center"/>
<Property Name="AmountMonth01" Type="Edm.Decimal" Precision="23" Scale="2" sap:aggregation-role="measure" sap:label="Jan" sap:filterable="false"/>
<Property Name="AmountMonth02" Type="Edm.Decimal" Precision="23" Scale="2" sap:aggregation-role="measure" sap:label="Feb" sap:filterable="false"/>
<Property Name="AmountMonth03" Type="Edm.Decimal" Precision="23" Scale="2" sap:aggregation-role="measure" sap:label="Mar" sap:filterable="false"/>
<Property Name="AmountMonth04" Type="Edm.Decimal" Precision="23" Scale="2" sap:aggregation-role="measure" sap:label="Apr" sap:filterable="false"/>
<Property Name="AmountMonth05" Type="Edm.Decimal" Precision="23" Scale="2" sap:aggregation-role="measure" sap:label="May" sap:filterable="false"/>
<Property Name="AmountMonth06" Type="Edm.Decimal" Precision="23" Scale="2" sap:aggregation-role="measure" sap:label="Jun" sap:filterable="false"/>
<Property Name="AmountMonth07" Type="Edm.Decimal" Precision="23" Scale="2" sap:aggregation-role="measure" sap:label="Jul" sap:filterable="false"/>
<Property Name="AmountMonth08" Type="Edm.Decimal" Precision="23" Scale="2" sap:aggregation-role="measure" sap:label="Aug" sap:filterable="false"/>
<Property Name="AmountMonth09" Type="Edm.Decimal" Precision="23" Scale="2" sap:aggregation-role="measure" sap:label="Set" sap:filterable="false"/>
<Property Name="AmountMonth10" Type="Edm.Decimal" Precision="23" Scale="2" sap:aggregation-role="measure" sap:label="Oct" sap:filterable="false"/>
<Property Name="AmountMonth11" Type="Edm.Decimal" Precision="23" Scale="2" sap:aggregation-role="measure" sap:label="Nov" sap:filterable="false"/>
<Property Name="AmountMonth12" Type="Edm.Decimal" Precision="23" Scale="2" sap:aggregation-role="measure" sap:label="Dec" sap:filterable="false"/>
<Property Name="Total" Type="Edm.Decimal" Precision="23" Scale="2" sap:aggregation-role="measure" sap:filterable="false"/>
<NavigationProperty Name="Parameters" Relationship="ZFI_LOS_TREE_SRV.assoc_7F4591C4FDF11E32F5E63F4334179465" FromRole="ToRole_assoc_7F4591C4FDF11E32F5E63F4334179465" ToRole="FromRole_assoc_7F4591C4FDF11E32F5E63F4334179465" sap:filterable="false"/>
</EntityType>
Workaround:
Changing totally the backend and fixing the number of levels of the hierarchy I could flat the levels, turning each of them into an attribute. From this, defining a fixed groupBy and setting the type of the table to AnalyticalTable, I got this result:
But there are some drawbacks, like the level columns needing to be present at table in order to the group by work, excel export does not reflects the tree display, the levels need to be fixed.
So, as I think the really good one solution for this scenario would be leverage the tree table, Is there any way to calculate the totals and subtotals via fiori elements in a tree table? Am I missing something?
Best Regards,
Pedro Lázaro
Request clarification before answering.
User | Count |
---|---|
31 | |
15 | |
10 | |
9 | |
7 | |
6 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.