cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

CDS Virtual Element Filter Requirement

dommeyer
Explorer
0 Kudos
5,049

Hi all,

we are currently working on a Fiori Elements Application. Therefore we are using a virtual element to calculate the current stock for a material. In the implementation of the virtual field we are calling a BAPI which returns the available stock quantity. Now we have the requirement in our list report to filter the stock quantities in the virtual field.

I read the question from che.eky, which shows that directly filtering virtual fields is not possible - only applying the filter on persistent fields (https://answers.sap.com/questions/13163381/cds-virtual-element-filter-doubt-clarification.html)

The question was asked about 2 years ago. So my question is: Is it still the case that virtual elements cannot be filtered? Is there any possibility to implement filtering on a virtual field because as I mentioned before this is a requirement we need for our application.

I am aware of the possibility of realizing the stock determination via CDS Views. However, we want to do this using the BAPI, because the standard transactions using this BAPI and any changes in the availability check also covered from the BAPI.

Thanks in advance!

Best regards
Dominik

Accepted Solutions (0)

Answers (3)

Answers (3)

manwell77t
Explorer
0 Kudos

I'm facing the same issue: it's a completely no-sense topic.

You found the documentation: "Implementing Filtering for Virtual Elements" (https://help.sap.com/docs/ABAP_PLATFORM_NEW/fc4c71aa50014fd1b43721701471913d/9019018679ea491cb55ce7e...).

thinking there's explained how to apply a filter on a virtual element. Next reading...

"Filtering on virtual elements requires the transformation of the given filter condition into a corresponding condition that does not use any virtual elements for the filter."

"The filter for virtual elements must be implemented in the related ABAP class. For each filter operator, the filtering must be transformed to a filter for the elements from which the virtual element is calculated."

To summarize: to filter a virtual element you have to transform the filter into a filter of non-virtual elements.

Useless.

che_eky
Active Contributor
0 Kudos

Hi Dominik,

It has been a while since I last worked with virtual elements. If things have not improved then you are not left with many options to fulfil your requirement. As I mentioned in my post it is possible to redefine the GET_ENTITYSET and call the standard CALL METHOD SUPER->ZZZ_MYDATA_GET_ENTITYSET and then filter the returned data. But this could lead to issues if you have large data sets, as with paging it will only fetch a subset of the data each time, so you cannot filter on the complete set.

Regards

Che

amangarg1
Contributor
0 Kudos

Hello Dominik,

You can still filter on Non-persisted fields by doing little extra implementations.

You can add annotation @objectModel.filter.transformedby and specify your ABAP class.

Add interface IF_SADL_EXIT_FILTER_TRANSFORM and implement interface method MAP_ATOM. Bind your filter(virtual) element and filter condition here and then you would be able to filter based on your calculated field.

Please find more details on link:

https://help.sap.com/docs/SAP_NETWEAVER_AS_ABAP_751_IP/cc0c305d2fab47bd808adcad3ca7ee9d/a423b19a682e...

Let me know if this helps.

Thanks,

Aman Garg

dommeyer
Explorer
0 Kudos

Hi aman9garg,

thanks for your response. I understand what you mean. But in my use case I need to filter the values in the virtual field and not the values in other fields. When I try to apply the filter to the virtual field I got these error message:

Best regards,
Dominik

vijay_jala2
Explorer
0 Kudos
Was this resolved ? please advise if it is resolved as we are facing similar situation.
Udita100
Associate
Associate
0 Kudos
Hello ,