Skip to Content
Oct 09, 2020 at 05:17 PM

CDS Virtual Element Filter doubt / clarification

288 Views Last edit Oct 09, 2020 at 05:19 PM 3 rev

Hi All,

Have been implementing virtual elements in a consumption view and things have been working great so far. However I have come across a scenario which does not work so I would like to pick your brains :0)

The consumption view contains a calculated field called CalcField1:

    @ObjectModel.readOnly: true
    @ObjectModel.virtualElement: true 
    @ObjectModel.virtualElementCalculatedBy: 'ABAP:ZCL_CALCULATE'    
    @ObjectModel.filter.transformedBy: 'ABAP:ZCL_FILTER'    
    cast('' as abap.char( 10 )) as CalcField1

The field is calculated correctly to give values A, B or C. But when I pass a filter on the calculated field it says you cannot filter on a calculated field:

The SAP help does talk about filtering in calculated fields:

Implementing ABAP Code Exits for Virtual Elements

But in there example they seem to talk about calculating a value and then using that value to filter on a persistent field fetched from the DB. Whereas my requirement is to filter on a transient field which is calculated on the fly.

If you have any thoughts or experiences please do share!



necvj.png (15.7 kB)
s301w.png (15.7 kB)