Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Filter operator: The addition EXCEPT is not the same as a negation of the WHERE condition

philipsalve
Discoverer
690

The documentation of the filter operator contains this note and does not elaborate or give examples.

The addition EXCEPT is not the same as a negation of the WHERE condition, particularly in the variant with a filter table.

Could someone please give an example where this is the case?

4 REPLIES 4

fedaros
Product and Topic Expert
Product and Topic Expert
0 Kudos
611

Hi Philip,

What I remind about EXCEPT is to be used on result sets, in fact I prefer the SQL which support MINUS operator, which make more sense to me and works in same way. See discussion:

https://blogs.sap.com/2014/07/31/an-introduction-to-hana-s-except-set-operator-function/

Also see a example:

https://help.sap.com/docs/SAP_NETWEAVER_DBOS/798ce92dc90c47aa8dd1092c185c45df/44e302913ee203fce10000...

https://blogs.sap.com/2017/10/04/calculation-view-intersect-and-minus-nodes/

Regards, Fernando Da Rós

611

If I understand well your answer, I think that the question is about FILTER and EXCEPT in ABAP, not about database/SQL.

fedaros
Product and Topic Expert
Product and Topic Expert
0 Kudos
611

That's correct sandra.rossi

This ABAP except is new for me.

Sandra_Rossi
Active Contributor
611

The sentence "The addition EXCEPT is not the same as a negation of the WHERE condition, particularly in the variant with a filter table" is taken from here: ABAP Documentation - FILTER, Filter Operator (addition EXCEPT).

I don't understand too. According to me, the result is always the same, i.e.

itab = FILTER #( itab EXCEPT IN ftab WHERE c1 = f1 ).

would be equivalent to (this syntax is INVALID of course😞

itab = FILTER #( itab IN ftab WHERE NOT ( c1 = f1 ) ).

Let's see what people have to say...