Skip to Content
0
Dec 23, 2020 at 03:41 PM

Load Values From a Smart Filter Dropdown List

163 Views Last edit Dec 23, 2020 at 08:30 PM 3 rev

Hi Experts,

Here I am again with another question. I created a button on my Fiori app to load customer parameters from a CDS view and use them in 4 different dropdown lists. The code is working fine and the values are being loaded. But when I click GO to execute the query, the app is not passing those values to the URI.

Here an example:

Inform customer number and click on the button Load Customer Parameters

Result after click:

Filled the other 2 fields and executed:

Here is the request sent:

GET UIShipmentSet?$skip=0&$top=20&$filter=Customer%20eq%20%271001902%27%20and%20Material%20eq%20%271000039-CONTI%27%20and%20OrderQty%20eq%20%274%27%20and%20RequestDate%20eq%20datetime%272020-12-23T00%3a00%3a00%27&$select=Plant%2cMaterial%2cConfirmedQty%2cShuttleFlag%2cShippingFees%2cDeliveryDate%2cDeliveryTime%2cDescription

If I select manually the options from the list, I have this request:

GET UIShipmentSet/$count?$filter=Customer%20eq%20%271001902%27%20and%20Material%20eq%20%271000039-CONTI%27%20and%20OrderQty%20eq%20%274%27%20and%20RequestDate%20eq%20datetime%272020-12-23T00%3a00%3a00%27%20and%20Studded%20eq%20true%20and%20ShippingMethod%20eq%20%2701%27%20and%20AcceptSaturday%20eq%20true%20and%20CustomerCluster%20eq%20%27R%27

Here is the code to load the parameters:

onLoadParameters: function(oEvent) { var oModel = new sap.ui.model.odata.ODataModel("/sap/opu/odata/sap/ZLE_SOURCING_LOGIC_SRV_BKP_SRV/"); // connect to OData service var customer = this.getView().byId("smartFilter").getControlByKey("Customer").getValue(); // create new variable and bind to smart filter parameter // MessageToast.show(customer); // show message toast var oFilters = [ new sap.ui.model.Filter("kunnr", "EQ", customer) ]; // create filter for OData query var sStudded = this.getView().byId("smartFilter").getControlByKey("Studded"); // create new variable and bind to smart filter parameter var sSaturday = this.getView().byId("smartFilter").getControlByKey("AcceptSaturday"); // create new variable and bind to smart filter parameter var sShipping = this.getView().byId("smartFilter").getControlByKey("ShippingMethod"); // create new variable and bind to smart filter parameter var sInventory = this.getView().byId("smartFilter").getControlByKey("CustomerCluster"); // create new variable and bind to smart filter parameter
oModel.read("/ZI_SD_CUSTOMER_PARAMETERS", { // read OData entity filters: oFilters, // using the filter created above urlParameters: { "$select": "katr2,katr5,katr7,vsbed" }, // using the following parameters to select success: function(oData, response) { if (oData.results[0].katr7 == 'X') { sStudded.setValue(sStudded.mAggregations.items[1].mProperties.text); } else { sStudded.setValue(sStudded.mAggregations.items[0].mProperties.text); } if (oData.results[0].katr5 == 'N') { sSaturday.setValue(sSaturday.mAggregations.items[1].mProperties.text); } if (oData.results[0].katr5 == 'Y') { sSaturday.setValue(sSaturday.mAggregations.items[0].mProperties.text); } var n = sShipping.mAggregations.items["length"]; var i = 0; for (i = 0; i < n; i++){ if (sShipping.mAggregations.items[i].mProperties.key == oData.results[0].vsbed){ sShipping.setValue(sShipping.mAggregations.items[i].mProperties.text); }; }; n = sInventory.mAggregations.items["length"]; i = 0; for (i = 0; i < n; i++){ if (sInventory.mAggregations.items[i].mProperties.key == oData.results[0].katr2){ sInventory.setValue(sInventory.mAggregations.items[i].mProperties.text); }; }; }.bind(this), error: function(oError) { MessageToast.show("Error loading customer parameters"); } }); },

Why the app is not getting the automatic filled parameters and using them to create the request?

Attachments

n5ugk.png (56.9 kB)
2wt1r.png (32.2 kB)
zfnfh.png (35.1 kB)
qmy0f.png (35.1 kB)
rloja.png (32.2 kB)
3g0li.png (56.9 kB)