filtering data through odata service and get distinct data
Wed Mar 13 2024 08:39:57 GMT+0000 (Coordinated Universal Time)
Saved by
@deepaksingh
function getDistinctLocations(selectedProducts, selectedCharNums) {
var productFilterString = "";
selectedProducts.forEach(function(product, index) {
if (index > 0) {
productFilterString += " or ";
}
productFilterString += "PRODUCT eq '" + product + "'";
});
var charNumFilterString = "";
selectedCharNums.forEach(function(charNum, index) {
if (index > 0) {
charNumFilterString += " or ";
}
charNumFilterString += "CHARNUM eq '" + charNum + "'";
});
var oModel = new sap.ui.model.odata.v2.ODataModel("/YourODataService");
oModel.read("/YourEntitySet", {
urlParameters: {
"$apply": "groupby((LOCATION))",
"$filter": productFilterString + " and (" + charNumFilterString + ")"
},
success: function(data) {
// Process distinct locations data
// Populate a dropdown or list with distinct locations
},
error: function(error) {
// Handle error
}
});
}
content_copyCOPY
Comments