cancel
Showing results for 
Search instead for 
Did you mean: 

when * selected in the sap ui5 then filter code returns 2a instead of *(star)

former_member338801
Participant
0 Kudos
949

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.

former_member338801
Participant
0 Kudos

In addition to above details adding few console error as well. When I restrict status date then I am getting data upto 314 records max. Status date from 01-01-2016 to 30-05-2020.

In any other case getting 502 proxy error. How to handle this at front end level?

error : 502 proxy error The proxy server received an invalid response from an upstream server

502-proxy-error.png

former_member338801
Participant
0 Kudos

..........

Accepted Solutions (0)

Answers (1)

Answers (1)

venkateswaran_k
Active Contributor
0 Kudos

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.

former_member338801
Participant
0 Kudos

As I said it worked in few cases when data count is not huge. It keeps coming so not intermittent issue.

thanks for your response.