I have added a field to the Supplier List Fiori app by extending the underlying CDS views C_SupplierList
and C_Supplier
. This new field holds a concatenation of the Supplier's Industry sectors in a string. It is fetched from a table function. The data is fetched correctly. The problem is that the filter for that field acts upon a string: if the user types an industry code in the filter, the returned suppliers are the ones having only this industry. If a supplier has the requested industry plus any other one, the concatenated string does match the filter and the supplier is not returned.
I would like to change the behavior of the filter to act as "Covers pattern" even when the user has selected "Equals to".
However, since the top CDS view C_SupplierList
is an unmanaged query, I don't know how to change the behavior of the filter without modifying the implementing class CL_FAP_SUPPLIER_LIST_V2
.
I've tried to use annotation @ObjectModel.filter.transformedBy:
on the Industry codes field in the extension of C_SupplierList
. However, that annotation seems to be incompatible with managed queries. When I'm trying to access the tile I get the following error from the Gateway:
Usage of annotation OBJECTMODEL.VIRTUALELEMENTCALCULATEDBY without annotation OBJECTMODEL.FILTER.TRANSFORMEDBY on element INDUSTRIES is not allowed
I've tried to make the new field a calculated Virtual Element by adding the following annotations and creating a calculating class:
@ObjectModel.readOnly: true
@ObjectModel.virtualElement:true
@ObjectModel.virtualElementCalculatedBy: 'ABAP:ZCL_BUPA_INDUSTRIES_CALC_EXIT'
@ObjectModel.filter.transformedBy: 'ABAP:ZCL_BUPA_INDUSTRIES_FILTER'
But the Gateway gives the following error:
Annotation OBJECTMODEL.VIRTUALELEMENTCALCULATEDBY is not allowed for current entity type with OBJECTMODEL.QUERY.IMPLEMENTEDBY
The only left choice seems to be to edit the Implementing class for the unmanaged query, but it is a standard SAP object and I don't want to touch it. Is it possible to extend it ? Is there another way to change the default filter's behavior ?
if you believe that setting up the @Search using standard annotations is not possible directly in CDS C_SupplierList
, I took a brief look at the code and found that I could enhance the method CL_FAP_SUPPLIER_SEL_BUILDER_V2->if_fap_supplier_sel_builder_2~prepare_where_clause
. I would suggest checking for the Fieldname and setting the filter accordingly.