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

In SAP CDS Views, the global search functionality is not working for calculated or derived fields.

Debashis2
Discoverer
0 Kudos
399

In SAP CDS Views, the global search functionality is not working for calculated or derived fields.

We have added the annotation @search.searchable:true at the header level and @search.defaultSearchElement at the derived/calculated field level. Additionally, we attempted to separate the calculation field into a view entity and integrated it with another root entity where the search is applied. However, this approach also did not resolve the issue.

The system is throwing a dump with the error TRIGGER_DATABASE_FAILURE_DUMP.

Could you please advise if there is any workaround to make the global search work for calculated or derived fields in CDS views?

Accepted Solutions (0)

Answers (1)

Answers (1)

AndreasMuno
Product and Topic Expert
Product and Topic Expert
0 Kudos

Thank you for your request, @Debashis2.

The following response is AI generated by SAP's "Joule for Consultants" chat bot. Please verify the response, accordingly.

"

Workaround for Global Search in CDS Views for Calculated Fields

Global search functionality in SAP CDS views does not support calculated or derived fields directly due to limitations in search annotations. Searching a calculated field is not feasible, as SAP allows only persisted fields in the database to be search-enabled [1].

To workaround these limitations, consider implementing the following options:

  1. Persist Calculated Values: If feasible, persist the calculated values in a physical field within the underlying database table. By storing the calculated values, you can then use search annotations like @Search.searchable: true and @Search.defaultSearchElement: true directly on persisted fields.

  2. Custom Filtering: Instead of a global search, introduce the calculated fields in a filter list. This approach allows users to filter data based on calculated attributes in the UI [1].

  3. Text Search with Associations: Use association with other CDS views that allow text searches, like I_TextObjectPlainLongText, to enable complex search scenarios. This requires additional setup in maintaining view associations but can provide a workaround where necessary [2].

These methods provide alternatives to achieve the desired search capabilities within the limitations of CDS views for calculated data."  

If this response answers your question, please mark it accordingly. Thank you.