cancel
Showing results for 
Search instead for 
Did you mean: 

CDS Virtual Element Calculate and Filter option to same field

former_member644343
Discoverer
0 Kudos

I have a Scenario where the field should be calculated and should have a filter option to the same field..

tried with below scenario however, couldn't able to resolve it.

Accepted Solutions (0)

Answers (2)

Answers (2)

MioYasutake
Active Contributor
0 Kudos

Hi Manasa Sanga,

In order to apply filter on a virtual element, interface if_sadl_exit_calc_element_read needs to be implemented. Please see the Use Case 2 in the following link.

https://help.sap.com/viewer/cc0c305d2fab47bd808adcad3ca7ee9d/7.51.12/en-US/04e64a8ffffe49b8a8a546979...

Best regards,

Mio

udita10
Explorer
0 Kudos

himioyasutake ,

Is it true that adding a filter on a field calculated by virtual class can lead to performance downgrading?

Then why is it advised to put a filter on a field whose value is getting calculated via a virtual class?

Thanks,

Udita Saklani

MioYasutake
Active Contributor
0 Kudos

Hi udita10,

The role of IF_SADL_EXIT_FILTER_TRANSFORM is to replace the filter condition on the calculated field with a condition for original the persistent field, so I don't think this would harm performance.

former_member644343
Discoverer
0 Kudos
@ObjectModel.virtualElement
      @ObjectModel.filter.transformedBy: 'ABAP:ZCL_DEMO_CDS_CALC'
      @EndUserText.label: 'Period'
      @UI.selectionField: [{ position: 50 }]
      @Consumption.valueHelpDefinition:
      [{ entity             : {name : 'ZI_PERIOD_VH',
      element               : 'YearMonth'} }]
      cast( '000000' as vdm_yearmonth preserving type ) as YearMonth,


      @EndUserText.label    : 'Period1'
      @UI.lineItem: [{position: 40 }]
      @ObjectModel.virtualElement: true
      @ObjectModel.virtualElementCalculatedBy: 'ABAP:ZCL_DEMO_CDS_CALC'
      cast( ' ' as vdm_yearmonth  )                     as YearMonth1,
gasparerdelyi
Active Participant
0 Kudos

I wonder what is your question about.

Is your problem that the ABAP class does not get called at all?
Do you want to make use of the virtual element in a non-analytical OData or Fiori use case? Or somewhere else?
Have you implemented the SADL exit interfaces?
Do you need help on using the condition factory for the filrter transfmoration?