Get Example source ABAP code based on a different SAP table
SELECT>, Difference of Multiple Tables This example demonstrates how a difference is created across multiple tables.
ABAP_SOURCE_CODE DEMO CL_DEMO_SELECT_EXCEPT
ABAP_DESCRIPTION Four columns of the same type from result sets from three database tables DEMO_JOIN1>, DEMO_JOIN2> and DEMO_JOIN3> are combined to different SELECT> statements using EXCEPT>>. The DDIC database tables are filled in the static constructor.
The first statement shows the default behavior with addition DISTINCT> in the second EXCEPT> and without addition DISTINCT> in the first EXCEPT>. The first EXCEPT> already removes all rows from the result set because there is no row in DDIC database table DEMO_JOIN1> that is not in DDIC database table DEMO_JOIN2>. With the second EXCEPT> the result set remains empty.
The second statement shows the behavior of EXCEPT> together with INTERSECT>. INTERSECT> inserts no rows from DDIC database table DEMO_JOIN2> and EXCEPT> inserts no rows from DDIC database table DEMO_JOIN3> but removes one row from the result set.
The third statement is the same as the second, except that parentheses have been inserted here. First, the parentheses are evaluated. EXCEPT> inserts no rows from DDIC database table DEMO_JOIN3 > and removes one row from DEMO_JOIN2>. Afterwards, the result set of the parentheses is completely inserted into the result set of DEMO_JOIN1> but without inserting a row.