SAP WITH ASSOCIATIONS ABEXA



Get Example source ABAP code based on a different SAP table
  



WITH, Exposing Associations
This example demonstrates how CDS associations are exposed using WITH ASSOCIATIONS after a common table expression.

ABAP_SOURCE_CODE
DEMO CL_DEMO_CDS_WITH_ASSOCIATIONS

ABAP_DESCRIPTION
The common table expressions in this example access the CDS views demo_cds_expose_assoc_1 and demo_cds_expose_assoc_1a of the executable example for exposing CDS associations in the SELECT list of CDS views. The subqueries of the common table expressions +cte_2, +cte_2a, +cte_3, and +cte_3a match the queries of the CDS views demo_cds_expose_assoc_2, demo_cds_expose_assoc_2a, demo_cds_expose_assoc_3, and demo_cds_expose_assoc_3a used in the executable example. The additions WITH ASSOCIATIONS expose the CDS association _demo_join2 of the data sources of the subqueries. In the case of the CDS views, this is done in their SELECT list. When accessed using the path expression in the main queries of the WITH statements, the exposed CDS associations produce the exact same results as the corresponding accesses in the example for the CDS views. This demonstrates that the result sets of the subqueries are used as the left side of the join instances.