ABAP Keyword Documentation → ABAP - Dictionary → ABAP CDS in ABAP Dictionary → ABAP CDS - Data Definitions → ABAP CDS - DDL for Data Definitions → ABAP CDS - DEFINE VIEW → ABAP CDS - SELECT → ABAP CDS - SELECT, select_list → ABAP CDS - SELECT, element
ABAP CDS - SELECT, association
Other versions:
7.31 | 7.40 | 7.54
Syntax
... path_expr
Effect
Uses a path expression path_expr to publish a CDS association as an element of the SELECT list of a CDS view. The path expression publishes its final CDS association for use in other CDS views or in ABAP SQL:
- A different CDS view can evaluate the CDS association in its path expressions.
- The CDS association can be used in ABAP SQL path expressions.
The current view is the source data source of the published 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 source data source of the CDS association that occur in the ON condition must also be specified as elements of the current SELECT list. If a path expression contains more than one CDS association, this type of element must be specified as a path expression closed by the field, with the same attributes as the path expression used for publishing.
Like every element, a CDS association published 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 results set, a field of the CDS database view of the CDS 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.
Notes
- When a CDS association is published, care should be taken that the publisher view itself is the source data source of the published CDS association and not the data source of the view. More specifically, when CDS associations are published that were already published by the data source of the current view, this view replaces the original view as the source data source of the CDS association. The left side of an instance of a join expression created for the published CDS association is the results set of the current view.
- When a CDS association with a filter condition cond_expr is published, the SELECT list must define an alternative element name alias using AS.
- When publishing 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 target data source to assign start values to the input parameters.
- That the names of the elements of a SELECT list have to be unique applies in particular also for the publication of a CDS association using the path expression path_expr. There must be not other element with this name. If necessary, AS must be used to define an alternative element name alias for the CDS association.
- A CDS association can be published multiple times with various alternative element names. This allows you to use different filter conditions cond_expr.
- Special rules apply to the publication of CDS associations in SELECT statements joined with UNION.
Example
The following CDS view opens its own CDS association _spfli and the CDS association _sflight published by its target data source demo_cds_assoc_spfli. The fields of the source data 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 published using _spfli._sflight, path expressions _spfli.carrid and _spfli.connid must be used accordingly. The element scarr occurs twice, which means that an alternative element name must be defined using AS.
@AccessControl.authorizationCheck: #NOT_REQUIRED
define view demo_cds_publish_assoc
as select from
scarr
association to demo_cds_assoc_spfli as _spfli on
scarr.carrid = _spfli.carrid
{
_spfli,
scarr.carrid as scarr_carrid,
_spfli._sflight,
_spfli.carrid,
_spfli.connid
}