Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
cancel
Showing results for 
Search instead for 
Did you mean: 
Kishannaicker
Participant
Hello community,

 

This month our team faced a blocker issue of case sensitive filter in SAP Fiori List Report applications supporting Nodejs / Java CAP Model as backend. The business wanted a solution with case insensitive filtering of selection fields in List Report applications. After so many research and blog reviews I have found a simple solution to this.

At the time I write this post, SAP Fiori List Report and Java CAP backend does not support filter with case sensitivity.

Odata provide some filter parameter that help you to filter with case-INSENSITIVE

We can add the condition "tolower" from frontend in the oData filter query by using the onBeforeRebindTableExtension method of the grid table in ListReportExtension controller.

Step 1 : Create a function with input parameter as oEvent of the grid table rebind method and access all the filters applied to the grid table.
caseInsensitiveFilters: function (oEvent) {

var oBindingParams = oEvent.getParameter("bindingParams");
var oFilters = oBindingParams.filters;

var exceptionFilters = ["STATUS","PACKAGE_ID"];
oFilters.forEach(function (x) {
if (x.aFilters) {
x.aFilters.forEach(function (y) {
if (y.aFilters) {
y.aFilters.forEach(function (z) {
if (z.sPath && typeof z.oValue1 === 'string' && !exceptionFilters.includes(z.sPath)) {
z.sPath = "tolower(" + z.sPath + ")";
z.oValue1 = "'" + z.oValue1.toLowerCase().toString() + "'";
}

} else if (y.sPath && typeof y.oValue1 === 'string' && !exceptionFilters.includes(y.sPath)) {
y.sPath = "tolower(" + y.sPath + ")";
y.oValue1 = "'" + y.oValue1.toLowerCase().toString() + "'";
}
});
} else if (x.sPath && typeof x.oValue1 === 'string' && !exceptionFilters.includes(x.sPath)) {
x.sPath = "tolower(" + x.sPath + ")";
x.oValue1 = "'" + x.oValue1.toLowerCase().toString() + "'";
}
});


},

 

Step 2: Call the above function in onBeforeRebindTableExtension method and pass the oEvent as input parameter.

 
onBeforeRebindTableExtension: function (oEvent) {
this.caseInsensitiveFilters(oEvent);
},

 

Note : I have used nested ForEach loop for filters array because I had custom filters along with standard (native) selection field filters in my List Report application.

 

Conclusion :: We hardly modify the URI of ODATA service in our font end SAP UI5 code. Most of us use API provided from SAP, we only provide the parameter to API function, then let the API from SAPUI5 library handle the ODATA service URL. In short, we cannot, or hardly, modifying the oData GET request as we want, but use the standard API instead. This is just work around so I’m not sure how long it would work, but it's worth trying for now.
5 Comments
former_member611303
Participant
0 Kudos
Hello Kishan,

Great Blog

It's really very helpful.

Thanks
hemil_1993
Explorer
0 Kudos
Hi Kishan,

It's very helpful. great job.

Thanks
hemchand_sharma
Active Participant
0 Kudos
Helpful
Richie
Product and Topic Expert
Product and Topic Expert
0 Kudos
Great blog, many thanks kishannaicker .

It worked a treat for me. A good workaround for oData V2 services that don't support Using Case Insensitive Filtering as mentioned in v4 here:

https://sapui5.hana.ondemand.com/sdk/#/topic/609c39a7498541559dbef503c1ffd194
KM11
Participant
0 Kudos
Great blog. Worked like a charm.
Labels in this area