on 2020 May 30 12:45 PM
Hi Experts,
I am facing one issue in the sapui5.
1) There are 4 fields where the filter applied and I am getting data in the sap ui5 read call. It is working in when selected value is TRANSPORT12 and it failed when it is selected as '*' . You can check below filter out from the network tab in case of star(*) , it is showing 2a. That is where issue exist how can I keep it as star that is selected by user in the combo box. I have checked at the back end service it is giving me correct records but in the fronend only looks like issue exist.
Scenario 1: ZZ_USERNAME = 'TRANSPORT12', ZZ_AREA= '', ZZ_STATUS_DATE='' and SHOW_PRD=''
Scenario 2: ZZ_USERNAME = '*', ZZ_AREA= '', ZZ_STATUS_DATE='' and SHOW_PRD=''
Count = let say 21
TestSet$filter=ZZ_USERNAME%20eq%20%27TRANSPORT12%27%20and%20ZZ_AREA%20eq%20%27%27%20and%20(ZZ_STATUS_DATE%20ge%20%27%27%20and%20ZZ_STATUS_DATE%20le%20%27%27)%20and%20SHOW_PRD%20eq%20%27%20%27
Count = no change in the count it should return 12 records let's say
TestSet$filter=ZZ_USERNAME%20eq%20%27%2a%27%20and%20ZZ_AREA%20eq%20%27%27%20and%20(ZZ_STATUS_DATE%20ge%20%27%27%20and%20ZZ_STATUS_DATE%20le%20%27%27)%20and%20SHOW_PRD%20eq%20%27%20%27
Backend service :
/opu/odata/sap/Service_SRV/TestSet/?$filter=(ZZ_USERNAME eq 'TRANSPORT12') and (ZZ_AREA eq '') and (ZZ_STATUS_DATE ge '' and ZZ_STATUS_DATE le '') and (SHOW_PRD eq '')
UI filter code in the controller:
filterRecords: function () {
var that = this;
var userId = sap.ushell.Container.getService("UserInfo").getUser().getId();
var aDate = that.getView().byId("DRS3").getDateValue();
var adateFormat = sap.ui.core.format.DateFormat.getDateInstance({
pattern: "yyyMMdd"
});
var adateFormatted = adateFormat.format(aDate);
var bDate = that.getView().byId("DRS3").getSecondDateValue();
var bdateFormat = sap.ui.core.format.DateFormat.getDateInstance({
pattern: "yyyMMdd"
});
var bdateFormatted = bdateFormat.format(bDate);
var pakageOwner = that.getView().byId("combo1").getValue();
//var pakageOwner = "transport12";
var businessArea = that.getView().byId("combo2").getValue();
// var businessArea = "TECH";
var showPrd = that.getView().byId("prdflag").getState();
if (!showPrd) {
showPrd = ' ';
} else {
showPrd = 'X';
}
// //alert(adateFormatted + "from" + bdateFormatted + " " + pakageOwner + " " + businessArea + " " + showPrd);
var url = "/sap/opu/odata/sap/Service_SRV/";
// var andFilter = [];
//var orFilter = [];
var andFilter = new Filter({
filters: [
new sap.ui.model.Filter({
path: "ZZ_STATUS_DATE",
operator: sap.ui.model.FilterOperator.GE,
value1: adateFormatted
}),
new sap.ui.model.Filter({
path: "ZZ_STATUS_DATE",
operator: sap.ui.model.FilterOperator.LE,
value1: bdateFormatted
})
],
and: true
});
var allfilters = [new sap.ui.model.Filter({
path: "ZZ_USERNAME",
operator: sap.ui.model.FilterOperator.EQ,
value1: pakageOwner
}),
new sap.ui.model.Filter({
path: "ZZ_AREA",
operator: sap.ui.model.FilterOperator.EQ,
value1: businessArea
}),
andFilter,
new sap.ui.model.Filter({
path: "SHOW_PRD",
operator: sap.ui.model.FilterOperator.EQ,
value1: showPrd
})
];
var oModel = new sap.ui.model.odata.v2.ODataModel(url);
sap.ui.getCore().setModel(oModel);
var oModel1 = new sap.ui.model.json.JSONModel();
oModel.metadataLoaded().then(function (oSuccess) {
oModel.read("/PACKAGESet", {
filters: allfilters,
success: function (oData) {
lv_BusyDialog.close();
var data = oData;
oModel1.setData(data);
that.getView().setModel(oModel1, "key");
},
error: function (oError) {
//alert("error");
}
});
}, function (oError) {
});
}
Let me know in case of any more details.
Hi
When you are using filter with * and EQ - which is contradict. You need to handle it at your service level.
Secondly the 502 error not necessarily the error at your end. It may be a temporary internet issue.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
61 | |
10 | |
7 | |
7 | |
6 | |
6 | |
6 | |
5 | |
5 | |
5 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.