SAP CDS SELECT LIST ASSOCIATION V2 Get Example source ABAP code based on a different SAP table
SAP Help
ABAP_CDS_DDL - CDS View Entity, SELECT>, expose_assoc> ABAP_SYNTAX ... path_expr> $[AS alias$]> What does it do? Uses a path expression path_expr> > to expose a CDS association> as an element> of the SELECT> list> of a CDS view entity>. A path expression can consist of one or more associations, and the final CDS association is exposed for use in other CDS views> or in AB_SQL : A different CDS view can evaluate the CDS association in its path expressions>. The CDS association can be used in AB_SQL path expressions>. The current view is the association source> of the exposed CDS association and any join expression created for a path expression from the CDS association uses the current CDS view entity as its left side. All fields of the association source that are used in the ON> condition must also be specified as elements of the current SELECT > list. Such an element must be specified by exactly the same path expression as used for exposing the association. It must contain the same associations in the same sequence and with the same attributes>. A CDS association can be exposed multiple times with various alternative element names alias> defined using the keyword AS> (see example below). This makes it possible to use different filter conditions> cds_cond >. However, this is only possible for simple CDS associations and not for compositions and to-parent associations. An exposed CDS association is part of the SELECT> list. It is not, however, part of the result set, nor a component of the type defined in ABAP with respect to the CDS view entity. The names of the elements of a SELECT> list must be unique. This applies in particular also for the publication of a CDS association> using a path expression. There must be no other element with this name. If necessary, AS> must be used to define an alternative element name alias > for the CDS association. If no alternative element name alias> is defined, the element name is defined by the name of the CDS association used in the path expression. When a CDS association with a filter condition> cds_cond> is exposed, an alternative element name alias> using AS> is mandatory. Latest notes: When a CDS association is exposed, the exposing view itself is the association source> of the exposed CDS association - not the data source of the exposing view. Especially when CDS associations are exposed that were already exposed by the data source of the current view, the current view replaces the original view as the association source. When a join expression is created for the current view, the left side of the join expression is the result set of the current view. When exposing a CDS association> using a path expression path_expr> > in the SELECT> list, it is not possible to pass actual parameters to any input parameters> of the association target> to assign start values to the input parameters. Special rules apply to the publication of CDS associations in SELECT > statements joined with a set operator>. BEGIN_SECTION SAP_INTERNAL_HINT It is syntactically allowed to specify the kind of join expression with [inner]> or [left outer]> when exposing an association in a SELECT> list. But this has no effect. END_SECTION SAP_INTERNAL_HINT NON_V5_HINTS ABAP_HINT_END ABAP_EXAMPLE_VX5 The following CDS view entity exposes its own CDS association _spfli > and the CDS association _sflight> exposed by its association target> demo_cds_assoc_spfli>. The fields of the association source>, which are used in the ON> conditions of the CDS associations, are specified in the SELECT> list. In the case of the CDS association exposed using _spfli._sflight>, path expressions _spfli.carrid> and _spfli.connid> are specified accordingly. The element carrid> occurs twice, therefore, an alternative element name must be defined using AS>. DDLS DEMO_CDS_EXPOSE_ASSOC_VE ABAP_EXAMPLE_END ABAP_EXAMPLE_VX5 The following CDS view entity exposes its own CDS association _spfli > with a filter condition. The fields of the association source>, which are used in the ON> condition of the CDS association, are specified in the SELECT> list using the same filter condition. Once this has been done, the same association can be exposed again with different filter conditions. New alias names are required. DDLS DEMO_CDS_EXPOSE_ASSOC_FILTER ABAP_EXAMPLE_END ABAP_EXAMPLE_ABEXA Exposing CDS Associations> ABAP_EXAMPLE_END