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.