cancel
Showing results for 
Search instead for 
Did you mean: 

oData filtering with 'OR' when using server mode is not working

Former Member
0 Kudos

Hi,

this is my code to search a string in several columns of a table.

the table is using an oData model with default operation mode = server mode.

when i try to user filter with 'or' ( and : false ) the query fails.

if i change operation mode to client mode or and : true it works but i don't want it.

what can i do??

the filter strings that is sent to gateways is a follows :

( ( startswith ( Kunnr , 'xxx' ) or ( startswith ( Mcod1 , 'xxx' ) )

			handleTableDialogSearch: function(oEvent) {
				var sValue   = oEvent.getParameter("value");
				var oBinding = oEvent.getSource().getBinding("items");
				var filters  = [];


				for(var i=0;i<oItems.length;i++){
					filters.push(new Filter(oItems[i].template, sap.ui.model.FilterOperator.StartsWith, sValue));
				}				


				var oFilter = new Filter({
					filters : filters , 
					and	 : false,
				});		


				oBinding.filter(oFilter);				


			}

error from GW:

2017-12-19 18:18:15.141270 The following problem occurred: HTTP request failed500,Internal Server Error,{"error":{"code":"/IWBEP/CM_MGW_RT/032","message":{"lang":"en","value":"Internal error occurred, contact your system administrator."},"innererror":{"application":{"component_id":"","service_namespace":"/SAP/","service_id":"ZSD_CRD_APP_SRV","service_version":"0001"},"transactionid":"318B3E7F9D9D0080E005A2500D490E51","timestamp":"20171219161815.0270790","Error_Resolution":{"SAP_Transaction":"Run transaction /IWFND/ERROR_LOG on SAP Gateway hub system (System Alias ) and search for entries with the timestamp above for more details","SAP_Note":"See SAP Note 1797736 for error analysis (https://service.sap.com/sap/support/notes/1797736)","Batch_SAP_Note":"See SAP Note 1869434 for details about working with $batch (https://service.sap.com/sap/support/notes/1869434)"},"errordetails":[{"code":"/IWBEP/CX_MGW_TECH_EXCEPTION","message":"Internal error occurred, contact your system administrator","propertyref":"","severity":"error","target":""}]}}} -

Accepted Solutions (0)

Answers (3)

Answers (3)

former_member185414
Active Contributor

Server mode means data filtering will happen on server via odata call.

Client mode means all processing will be local on the json model.

Regarding filter not working with 'or' & workign with 'and' , please post the exact filter clause so that we can advise.

0 Kudos

Hi Ankit

I have the same issue with 'OR' filter not working, but 'AND' works. This is how I set the 'OR' filters in the onSearch method.

if (sQuery) {
    this._oListFilterState.aSearch = [	
    new Filter({ filters: [
		   new Filter({ path: 'Name', operator: FilterOperator.Contains, value1: sQuery }),
		   new Filter({ path: 'Text', operator: FilterOperator.Contains, value1: sQuery })
                 ],
                 and: false
})];
}

This creates the following $filter part in the url with search query equals Test (sQuery = Test:

$filter=substringof(%27Test%27,Name)%20or%20substringof(%27Test%27,Text)

If I check the method io_tech_request_context -> get_filter() -> get_filter_select_options() it is empty. But with the 'and' conjunction it works. The $filter part looks then like this:

$filter=substringof(%27Test%27,Name)%20and%20substringof(%27Test%27,Text)

Thank you for your inputs and BR,

Emanuel

former_member185414
Active Contributor
0 Kudos

Good that your problem is solved.

former_member185414
Active Contributor
0 Kudos

Hi Emanuel,

It can be a bug in GW framework. Does the iv_filter_string have the value ?

Thanks and Regards,

Ankit Maskara.

Hi Anit

Yes the iv_filter_string has the value. We adjusted our gateway method to parse the filters by ourselves because we found a lot of articles, saying it's not always possible to get the select options. We are working with io_tech_request_context->get_osql_where_clause( ) this works fine for us.

Thanks for your reply anyway!

BR Emanuel