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 } }); }
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter