Ansicht
Dokumentation

ABENCDS_F1_PATH_EXPRESSION - CDS F1 PATH EXPRESSION

ABENCDS_F1_PATH_EXPRESSION - CDS F1 PATH EXPRESSION

CL_GUI_FRONTEND_SERVICES - Frontend Services   rdisp/max_wprun_time - Maximum work process run time  
This documentation is copyright by SAP AG.
SAP E-Book

- path_expr

... $[source.$]_assoc1$[ parameters$]$[attributes$]
           $[._assoc2$[ parameters$]$[attributes$] ... $] ...


Effect

Specifies an SQL path expression. Can be used either in a SELECT statement of a CDS view, or in the element list of a CDS projection view. A path expression of the CDS DDL is a string of CDS associations separated by periods (.) whose names are specified using _assoc1, _assoc2, and so on. The name of the CDS entity source in which the first CDS association is defined or exposed can be specified in front of this CDS association. The first CDS association of a path expression must be either:

  • Defined in the current CDS view.
  • Exposed as an element of the SELECT list or as an element list in a CDS view or CDS hierarchy that is a data source of the current view.

All further CDS associations must be exposed in the association target of the directly prefixed CDS association in the path expression. No CDS associations can be used in a path expression that are defined in an CDS abstract entity.

attributes can be used to specify attributes in angle brackets after every CDS association. These attributes define the following further properties of this section of the path expression:

  • Declaration of monovalency
  • Specified filter conditions

If the data source target of a specified CDS association is a CDS entity with input parameters, parameters must be used after the name _assoc to pass actual parameters to them. No parameters can be specified for a CDS association exposed as an element of a SELECT list.

Use of Path Expressions

Path expressions can be used as follows in the CDS DDL in ABAP CDS:

In the case of self associations in which the association target is the same as the association source, these usages are not possible in the CDS entity where they are defined.

When a non-aggregated element of a SELECT list is specified with aggregate expressions and in a WHERE condition or HAVING condition, the result of the path expression must be monovalent. This means that the cardinality of all CDS associations used is either "to 1" or the path expression can contain only filter conditions that are declared as monovalent using the addition 1:.

The following is evaluated when a CDS entity is accessed using a path expression:

  • The joins defined by the CDS associations, from left to right.
  • All other conditions of the CDS entities in question.

The path expression addresses the full result of this evaluation or a single element appended using .element.

Notes

  • The most simple path expression is the name of a single CDS association.
  • When joins are defined by CDS associations are implemented by path expressions, note that their left side is always the CDS entity that exposes the CDS association. This applies particularly to CDS associations that are exposed in data sources of CDS entities and passed on.
  • CDS DDL path expressions can also be used in conditions in the ABAP CDS DCL of ABAP CDS.
  • A CDS association whose association target does not expose a CDS association cannot be followed by any further associations in a path expression. More specifically, no further CDS associations can be made into a path expression after CDS associations whose association targets are DDIC database tables or DDIC views.
  • When the CDS associations of the path expressions of a view are implemented as joins, they are mapped to as few join expressions as possible. The ABAP annotation AbapCatalog.compiler.compareFilter is used as support here. The value true guarantees that CDS associations with semantically identical filter conditions do not produce differing join expressions.

Example

The following CDS view contains the simple path expression _scarr[inner].carrname in the SELECT list, whereby the attribute INNER is specified that controls the join type. The program DEMO_FROM_JOIN_TO_ASSOCIATION demonstrates that this view returns the same result as a directly programmed inner join in ABAP CDS or in .

Example

This example shows three CDS views, sales_order, business_partner, and invoice. The CDS view invoice uses its own CDS association and CDS associations from the other two views in path expressions:

  • The CDS association sales_order of the CDS view business_partner is specified as a data source after FROM. A filter condition guarantees that only certain orders can be used as data sources.
  • The separate CDS association invoice_header is used in a path expression as an operand in the WHERE condition.
  • The CDS association note_header of the CDS view sales_order is addressed using the alternative name bpa in business_partner and defined as an element of the SELECT list. This means this CDS association can also be used in CDS views that use invoice as a data source.
@AbapCatalog.sqlViewName: 'SALES_ORDER_VW'
define view sales_order as
  select from snwd_so
         association [0..1] to snwd_text_key as _note_header
           on snwd_so.note_guid = _note_header.node_key
  { * } // Include all fields from snwd_text_key

@AbapCatalog.sqlViewName: 'BPA_VW'
define view business_partner as
  select from snwd_bpa
         association [0..*] to sales_order
           on snwd_bpa.node_key = sales_order.buyer_guid
  { * }

@AbapCatalog.sqlViewName: 'SALESO_INV_VW'
define view invoice as
  select from
         /* Association "sales_order" with filter as data source */
         business_partner.sales_order[
           lifecycle_status <> 'C' and lifecycle_status <> 'X']
           as bpa_so //alias for data source
         /* Association only used in this view definition */
         association [0..1] to snwd_so_inv_head as _invoice_header
           on bpa_so.node_key = _invoice_header.so_guid
        { key bpa_so.node_key, //Field from ON-condition in _invoice_header
              bpa_so.so_id,
              bpa_so.note_guid, //Field from ON-condition in note_header
              bpa_so.lifecycle_status,
              /* Association is not exposed, but its element */
              _invoice_header.dunning_level,
              /* Association from data source is exposed here */
              bpa_so.note_header }
          /* Path expression in WHERE clause */
          where _invoice_header.dunning_level > '0';

Path Expressions, Use in the SELECT List






CPI1466 during Backup   BAL_S_LOG - Application Log: Log header data  
This documentation is copyright by SAP AG.

Length: 17707 Date: 20240419 Time: 210028     sap01-206 ( 180 ms )