2020 Feb 24 12:24 AM
A simple CDS view with a virtual element is created like below in S4 1809. I'm trying to use this as a basis for a consumption view for a ListReport.
I noticed that the Aggregation annotation on the Quantity field does not work with this. ADT comes up with an error "Calculated view not allowed in analytical ... ".
Creating the @Aggregation at a higher level consumption CDS gets a similar error.
Am I missing the intention of virtual elements? Why are they not allowed in consumption views that allow aggregation?
@AbapCatalog.sqlViewName: 'YWSSALESORDITEM'
@AbapCatalog.compiler.compareFilter: true
@AbapCatalog.preserveKey: true
@AccessControl.authorizationCheck: #CHECK
@EndUserText.label: 'Sales Order Item'
@OData.publish: true
@VDM.viewType: #BASIC
define view YWS_SalesOrderItem
as select from vbap
{
key vbeln as SalesOrder,
key posnr as SalesOrderItem,
@Semantics.unitOfMeasure
vrkme as Unit,
// @Aggregation.default: #SUM
@Semantics.quantity.unitOfMeasure: 'Unit'
kwmeng as Quantity,
matnr as Material,
arktx as MaterialDescription,
@Aggregation.default: #NONE
@ObjectModel.readOnly: true
@ObjectModel.virtualElement:true
@ObjectModel.virtualElementCalculatedBy: 'ABAP:YCL_WS_SALESORD_ITEM_VIRTUAL'
cast( '' as abap.char(45) ) as Status
}
2020 Feb 24 5:51 AM
It seems that they cannot be used together, check the documentation below:
-Mahesh
It seems that they cannot be used together, check the documentation below:
-Mahesh
2020 Feb 24 5:51 AM
It seems that they cannot be used together, check the documentation below:
-Mahesh
2020 Feb 26 11:20 PM
When it said "Calculated fields cannot be used together with the grouping or the aggregation function.' I kinda understand why that's the case when code tries to apply aggregation on the calculated field. But in the example above, the calculated view is "Status", the Aggregation field is Quantity. It sounds like it cannot be used together at all in the same CDS hierarchy.
That kinda limits the utility of the virtual element in reporting.
2020 Feb 29 2:56 PM
2020 Mar 03 6:27 AM
Hi Wilbert,
I also worked on similar kind of requirement and get to know that we cant use analytical annotations while using virtual element(even in 1909).
Regards
Abhijeet kankani
2021 Dec 15 1:49 PM
Hi Abhijeet,
What solution you applied then ? I have same requirement where need to ready long text in CDS with aggregation to generate Odata to consume it in Analytical KPI reports
2021 Dec 24 10:31 AM
kamakshij As we cant use both concept together, for our case there was no KPI based on long text so we just created new CDS view for long text and associate it to parent cds view and exposed in parent CDS. So using navigation one can retrieve the long text.
Hope it will help.
2024 Apr 17 2:35 PM
Were you able to solve this problem somehow? I have a case where a value of a field can be retrieved only using ABAP and I need to use this CDS in KPI. I've checked the solution that suggests associations. The field is displayed in the result CDS but it's empty - class is not called at all.
| User | Count |
|---|---|
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |