Ansicht
Dokumentation

ABENWITH_ASSOCS_REDIRECT_ABEXA - WITH ASSOCS REDIRECT ABEXA

ABENWITH_ASSOCS_REDIRECT_ABEXA - WITH ASSOCS REDIRECT ABEXA

General Data in Customer Master   CPI1466 during Backup  
This documentation is copyright by SAP AG.
SAP E-Book

WITH, Exposing Associations with a Redirect

This example demonstrates the addition REDIRECTED of WITH ASSOCIATIONS for common table expressions.

Source Code

Execute

Description

The common table expression +cte2 accesses a CDS view using the following source code:

This example demonstrates different redirects of the association target of the CDS association demo_cds_expose_assoc_1~\_demo_join2 exposed by +cte2 to a preceding common table expression +cte1:

  • The first WITH statement shows a simple example in which the association target demo_join2 of the CDS association _demo_join2 exposed by +cte2 occurs once under its name in +cte1 as a data source. Only demo_join2 can be specified after VIA. When the path expression +cte2\_demo_join2 is accessed, an inner join is created between the result sets of +cte2 and +cte1, whose ON condition compares the columns of the result sets defined by the CDS association.
  • The next WITH statements show examples in which the association target demo_join2 of the CDS association _demo_join2 exposed by +cte2 occurs twice as a data source in +cte1 under different names, src1 and src2.
  • src1 is specified after VIA in the redirect of the first WITH statement. The ON condition of the join instance created when the path expression is accessed uses the column of the result set determined bysrc1.

  • src2 is specified after VIA in the redirect of the second WITH statement. The ON condition of the join instance created when the path expression is accessed uses the column of the result set determined bysrc2.

  • The next two WITH statements repeat the preceding statements with a different WHERE condition in +cte1, which then produces different results.

The results of all reads are different from each other. The following reads demonstrate which join instances are created:

  • First, the same WITH statements are executed as above, but the CDS association is not exposed. Instead, the inner join between the two common table expressions is shown explicitly. More specifically, the difference between the ON conditions +cte2~d = +cte1~src1_d and cte2~d = +cte1~src2_d should be noted, which demonstrates the effect of the data sources specified using VIA.
  • The subqueries of the WITH statements are then executed as separate SELECT statements to store their results in internal tables for display purposes. Joins are also realized from internal tables using the value operator VALUE.

The example ensures that the results of associated reads also match each other.






PERFORM Short Reference   CL_GUI_FRONTEND_SERVICES - Frontend Services  
This documentation is copyright by SAP AG.

Length: 3607 Date: 20240329 Time: 160003     sap01-206 ( 37 ms )