Skip to Content
avatar image
Former Member

How to apply multiple filter in oData.read()

Hi Friends,

I need help in filter in to read oData. I need filter as following while performing oModel.read().

(

((USERID EQ 'KSA') OR (USERID EQ 'KSW'))

AND

((USERID NE 'KUMARNISH2') OR (USERID NE 'KUMARNISH3'))

)

If you see here there are multiple OR operation and atlast all are AND with each other.

I has following code:

var filters = [];

// var filters_ne = [];

var filter;

for (var i in employee){

var token = employee[i].getText();

if(token.startsWith("=")){

//equal to

filter = new sap.ui.model.Filter("UserID", "EQ",token.substring(1));

filters.push(filter);

}else if(token.startsWith("!")){

//not equal to

var notUser = token.substring(3);

notUser = notUser.substring(0,notUser.length-1);

filter = new sap.ui.model.Filter("UserID", "NE",notUser);

filters.push(filter);

}else{

//between

var userid = token.split("...");

filter = new sap.ui.model.Filter("UserID", "BT",userid[0],userid[1]);

filters.push(filter);

}

}

// filters.push(filters_ne);

// var allFilter = [];

// allFilter.push(filters_eq);

// allFilter.push(filters_ne);

// var filters = new sap.ui.model.Filter(allFilter, true);

this.getView().getModel().read("/I_Userdetails",{

filters :filters,

success : jQuery.proxy(this.updateUserData,this),

error : this.failed

});

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

1 Answer

  • Apr 05, 2016 at 10:50 AM

    Hi,

    Check weather this helps,

    https://scn.sap.com/thread/3762752

    Regards,

    Pradeep

    Add comment
    10|10000 characters needed characters exceeded