ABAP - Keyword Documentation →  ABAP - Reference →  Processing External Data →  ABAP Database Accesses →  Open SQL →  Open SQL - Operands and Expressions → 

Open SQL - Path Expressions

Syntax

... \_assoc1[parameters][ attributes]
   [\_assoc2[ parameters][ attributes]]
   [\...] ...

Effect

Specifies a CDS path expression. When a CDS view is accessed as a data source using the name of the CDS entity in a SELECT statement of a query, and this view publishes the associations _assoc in its SELECT list for use from outside, then these associations can be used as root elements of path expressions in the same statement. In a path expression, the names of associations _assoc1, _assoc2, ... are separated by backslashes (\). Associations specified after the root element must be published in the target data source of the directly prefixed association in the path expression.

When a SELECT statement is compiled using path expressions, the joins represented by these expressions are implicitly added to the FROM clause of the statement. The resulting additional data sources are implicitly evaluated at the occurrences of the path expressions. This respects the join conditions of the associations and the other conditions of the CDS views in question. Path expressions can be used:

An association has the cardinality defined implicitly or explicitly in the CDS view by default. Syntax warnings or syntax errors occur when the cardinality does not match the way the path expression is used in the SELECT statement. If the association has the cardinality “to 1”, the addition MANY TO ONE is added implicitly in the case of a LEFT OUTER JOIN on databases where this is supported. The consequences of this behavior should be noted. The following can be done after an association:

A path expression can be split across multiple lines of source code at the following places:

Certain restrictions apply to the associations of path expressions in Open SQL.

Notes

Example

Simple path specified for the association _spfli_scarr from the following CDS view:

@AbapCatalog.sqlViewName: 'DEMO_CDS_ASSOC'
@AccessControl.authorizationCheck: #NOT_REQUIRED
define view demo_cds_association(
_spfli_scarr,
id,
carrier,
flight,
departure,
destination
)
as select from
spfli
association [1..1] to scarr as _spfli_scarr on
$projection.carrid = _spfli_scarr.carrid
{
_spfli_scarr,
key spfli.carrid,
key _spfli_scarr.carrname,
key spfli.connid,
spfli.cityfrom,
spfli.cityto
}    

The program DEMO_CDS_ASSOCIATION uses the following SELECT statement with the simple path \_spfli_scarr for the view and compares it with accesses to the data that work in the same way.

SELECT id,
       \_spfli_scarr-carrname AS carrier,
       flight,
       departure,
       destination
       FROM demo_cds_association
       INTO TABLE @DATA(result).

A SELECT statement that access the full SELECT list of the view and a SELECT statement that accesses a view with a join of the same type produce the same result.

Executable Examples



Continue
Open SQL - Path Expressions, attributes
Open SQL - Restrictions for Path Expressions
Example Path Expressions, Use in the SELECT List.
Example Path Expressions, Use in the FROM Clause