我有smartFilter和智能表,我试图从结果中排除项目。我有以下代码:
var oBindingParameters = oEvent.getParameter("bindingParams");
var currVal = this._aItemsForLink[0];
var filter = new Filter({filters:[
new sap.ui.model.Filter("RevisionNumber", sap.ui.model.FilterOperator.EQ, currVal.RevisionNumber),
new sap.ui.model.Filter("CompanyCode", sap.ui.model.FilterOperator.EQ, currVal.CompanyCode),
new sap.ui.model.Filter("FiscalYear", sap.ui.model.FilterOperator.EQ, currVal.FiscalYear),
new sap.ui.model.Filter("Invoice", sap.ui.model.FilterOperator.EQ, currVal.Invoice),
new sap.ui.model.Filter("InvoiceYear", sap.ui.model.FilterOperator.EQ, currVal.InvoiceYear)
],and : true});
oBindingParameters.filters = [filter];
有没有办法为此过滤器实现逻辑否定? 类似的东西:
WHERE NOT ( companycode = '...' and revisionnumber = '...' and accountingdocument = '...' and invoice = '...' and fiscalyear = '...' )
答案 0 :(得分:0)
形式 NOT(V1 = C1和V2 = C2和...... Vn = Cn)的逻辑表达式与此相同: V1 ne C1或V2 ne C2或。 .. Vn ne Cn 。 所以,在你的情况下,它将是:
var filter = new Filter({filters:[
new sap.ui.model.Filter("RevisionNumber", sap.ui.model.FilterOperator.NE, currVal.RevisionNumber),
new sap.ui.model.Filter("CompanyCode", sap.ui.model.FilterOperator.NE, currVal.CompanyCode),
new sap.ui.model.Filter("FiscalYear", sap.ui.model.FilterOperator.NE, currVal.FiscalYear),
new sap.ui.model.Filter("Invoice", sap.ui.model.FilterOperator.NE, currVal.Invoice),
new sap.ui.model.Filter("InvoiceYear", sap.ui.model.FilterOperator.NE, currVal.InvoiceYear)
],and : false});
请记住,SQL WHERE子句中的NE(Not Equal)运算符在应用于关键字段时可能非常昂贵。