SAP CDS SELECT LIST ASSOCIATION V1 Get Example source ABAP code based on a different SAP table
SAP Help
ABAP_CDS_DDL - DDIC-Based View, SELECT>, expose_assoc> ABAP_SYNTAX ... path_expr> $[AS alias$]> What does it do? Uses a path expression path_expr> > to expose a CDS association>, a CDS composition>, or a CDS to-parent association> as an element> of the SELECT> list> of a ABAP_CDS_V1_VIEW >. 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 expressions created for a path expression from the CDS association use the current CDS view as their left side. All fields of the association source of the CDS association that occur 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>. 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. Like every element, a CDS association exposed in this way is part of the SELECT> list and must also be specified in a name list>. It is not, however, part of the result set, a field of the CDS-managed DDIC view> of a ABAP_CDS_V1_VIEW >, or a component of a type defined in ABAP with respect to the CDS view. If no alternative element name alias> is defined, and there is no name list >, the element name is defined by the name of the CDS association named by the path expression. Latest notes: When a CDS association is exposed, the exposing view itself is the association source> of the exposed CDS association and 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 a CDS association with a filter condition> cds_cond> is exposed, an alternative element name alias> using AS> must be defined in the SELECT> list. 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. The name 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. Special rules apply to the publication of CDS associations in SELECT > statements joined with UNION>>. 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 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, which means that an alternative element name must be defined using AS>. DDLS DEMO_CDS_EXPOSE_ASSOC ABAP_EXAMPLE_END ABAP_EXAMPLE_ABEXA Exposing CDS Associations> ABAP_EXAMPLE_END