SAP CDS PATH EXPRESSION FILTER V1



Get Example source ABAP code based on a different SAP table
  


• WHERE ABAP_CDS_PATH_EXPR_V1

ABAP_CDS_DDL - DDIC-Based View, path_expr, Filter

ABAP_SYNTAX
... $[WHERE$] cds_cond ...

What does it do?
Filter condition for the current CDS association. If the join type is explicitly defined with INNER$|${LEFT OUTER$}, the addition WHERE must be specified explicitly. If this is not the case, WHERE must not be specified.
A filter condition is a condition cds_cond implemented as an expanded condition for the join when resolving the CDS association with the join in question. For the operands, general and special rules apply when specifying the condition.
If no filter condition is specified in the path expression, any default filter condition specified for the CDS association is used.



Latest notes:

In most cases, a filter condition modifies the join expression defined for a CDS association of a path expression on the database. This means that a separate join expression is defined for each CDS association with a filter condition by default. This is not necessary, however, if a CDS association is used more than once and the same filter condition is specified. This is why the ABAP annotation AbapCatalog.compiler.compareFilter can be used to configure whether the filter conditions of multiple CDS associations are compared semantically for the path expressions defined as joins when a view is activated. If the filter condition matches, the associated join expression is created only once, which generally improves performance. In most cases, it is best to use the annotation and it is automatically proposed when creating a CDS view in the ADT. The result sets of the two configurations can, however, differ.
NON_V5_HINTS
ABAP_HINT_END

ABAP_EXAMPLE_VX5
The following three views contain path expressions with filter conditions in their SELECT list that are implemented as join expressions upon activation.
DDLS DEMO_CDS_ASSOC_FILTER1
DDLS DEMO_CDS_ASSOC_FILTER2
DDLS DEMO_CDS_ASSOC_FILTER3
In the first view, the annotation AbapCatalog.compiler.compareFilter has the recommended value true. The conditions are detected as identical and the variants of the path expressions on a SAP HANA database looks something like this: CREATE VIEW 'DEMOCDSASSFI1' AS SELECT
'=A0'.'D' AS 'D_2',
'=A0'.'E' AS 'E_2',
'=A1'.'I' AS 'I_3',
'=A1'.'J' AS 'J_3'
FROM (
'DEMO_JOIN1' 'DEMO_JOIN1' INNER JOIN 'DEMO_CDS_ASJO2' '=A0' ON (
'=A0'.'D' = 'DEMO_JOIN1'.'D' AND
'=A0'.'D' = N'1'
)
) INNER JOIN 'DEMO_JOIN3' '=A1' ON (
'=A1'.'L' = '=A0'.'D' AND
'=A1'.'I' = N'2'
)
In the second view, AbapCatalog.compiler.compareFilter has the value false and a join expression is defined for each CDS association of the path expressions regardless of the identical conditions. This means that this variant looks like the variant of the third views (in which all conditions are different): CREATE VIEW 'DEMOCDSASSFI2' AS SELECT
'=A0'.'D' AS 'D_2',
'=A1'.'E' AS 'E_2',
'=A3'.'I' AS 'I_3',
'=A5'.'J' AS 'J_3'
FROM (
(
(
(
(
'DEMO_JOIN1' 'DEMO_JOIN1' INNER JOIN 'DEMO_CDS_ASJO2' '=A0' ON (
'=A0'.'D' = 'DEMO_JOIN1'.'D' AND
'=A0'.'D' = N'1'
)
) INNER JOIN 'DEMO_CDS_ASJO2' '=A1' ON (
'=A1'.'D' = 'DEMO_JOIN1'.'D' AND
'=A1'.'D' = N'1'
)
) INNER JOIN 'DEMO_CDS_ASJO2' '=A2' ON (
'=A2'.'D' = 'DEMO_JOIN1'.'D' AND
'=A2'.'D' = N'1'
)
) INNER JOIN 'DEMO_JOIN3' '=A3' ON (
'=A3'.'L' = '=A2'.'D' AND
'=A3'.'I' = N'2'
)
) INNER JOIN 'DEMO_CDS_ASJO2' '=A4' ON (
'=A4'.'D' = 'DEMO_JOIN1'.'D' AND
'=A4'.'D' = N'1'
)
) INNER JOIN 'DEMO_JOIN3' '=A5' ON (
'=A5'.'L' = '=A4'.'D' AND
'=A5'.'I' = N'2'
)

CREATE VIEW 'DEMOCDSASSFI3' AS SELECT
'=A0'.'D' AS 'D_2',
'=A1'.'E' AS 'E_2',
'=A3'.'I' AS 'I_3',
'=A5'.'J' AS 'J_3'
FROM (
(
(
(
(
'DEMO_JOIN1' 'DEMO_JOIN1' INNER JOIN 'DEMO_CDS_ASJO2' '=A0' ON (
'=A0'.'D' = 'DEMO_JOIN1'.'D' AND
'=A0'.'D' = N'1'
)
) INNER JOIN 'DEMO_CDS_ASJO2' '=A1' ON (
'=A1'.'D' = 'DEMO_JOIN1'.'D' AND
'=A1'.'D' = N'2'
)
) INNER JOIN 'DEMO_CDS_ASJO2' '=A2' ON (
'=A2'.'D' = 'DEMO_JOIN1'.'D' AND
'=A2'.'D' = N'3'
)
) INNER JOIN 'DEMO_JOIN3' '=A3' ON (
'=A3'.'L' = '=A2'.'D' AND
'=A3'.'I' = N'5'
)
) INNER JOIN 'DEMO_CDS_ASJO2' '=A4' ON (
'=A4'.'D' = 'DEMO_JOIN1'.'D' AND
'=A4'.'D' = N'4'
)
) INNER JOIN 'DEMO_JOIN3' '=A5' ON (
'=A5'.'L' = '=A4'.'D' AND
'=A5'.'I' = N'6'
)
ABAP_EXAMPLE_END