Ansicht
Dokumentation

ABENCDS_SELECT_LIST_ENTRY_V2 - CDS SELECT LIST ENTRY V2

ABENCDS_SELECT_LIST_ENTRY_V2 - CDS SELECT LIST ENTRY V2

BAL_S_LOG - Application Log: Log header data   CL_GUI_FRONTEND_SERVICES - Frontend Services  
This documentation is copyright by SAP AG.
SAP E-Book

- CDS View Entity, SELECT, element

... ${ $[@element_annot1$]
      $[@element_annot2$]
      ...
        $[KEY$]   ${ field             $[AS alias$] $}
              $| ${ expose_assoc      $[AS alias$] $}
              $| ${ path_expr.element $[AS alias$] $}
              $| ${ literal            AS alias  $}
              $| ${ parameter          AS alias  $}
              $| ${ session_variable   AS alias  $}
              $| ${ aggr_expr          AS alias  $}
              $| ${ arith_expr         AS alias  $}
              $| ${ builtin_func       AS alias  $}
              $| ${ reuse_exp          AS alias  $}
              $| ${ case_expr          AS alias  $}
              $| ${ cast_expr          AS alias  $}
                  ...
    $}


Effect

Defines an element of a SELECT list of a CDS view entity. The names of the elements in a SELECT list must be unique and they are in the same namespace as the parameters of the view.

Additions

1. ... @element_annot ...

2. ... KEY

3. ... AS alias

Effect

Specifies individual elements in the SELECT list of a CDS view entity.

  • field defines an element of a data source data_source of the current CDS view entity as an element. The field name can be prefixed with the name of the data source or its alternative name. The prefix is separated using a period (.). AS can be used to define an alternative element name alias.
If the view entity makes use of multiple data sources by using one or more join expressions, then all elements in the SELECT list must be prefixed with the name of their data source separated by a period (.). The prefix is required in all cases, even if the field names are unique.
  • path_expr.element specifies an element element of the association target of the last CDS association of the path expression path_expr. The element defined in this way is part of the result set of the CDS view entity and a component of a type defined in ABAP with respect to the CDS view entity. If no alternative element name alias is defined, the element name is defined by the name of the element named by the path expression.
  • literal can be used to declare a literal. AS must be used to define an alternative element name alias.
  • parameter can be used to specify a parameter from the parameter list. An alternative element name using the keyword AS must be defined, and it cannot be the name pname of the parameter.
  • session_variable can be used to specify a session variable. AS must be used to define an alternative element name alias.
  • reuse_exp reuses an expression defined in the SELECT list in another operand position of the same CDS view entity. An alternative element name specified using AS is required.
  • aggr_expr, arith_expr, builtin_func, case_exp, and cast_expr can be used to specify aggregate expressions, arithmetic expressions, calls of built-in functions, case distinctions, and cast expressions. The expressions and functions are evaluated by the database system when the CDS view entity is accessed. An alternative element name alias must be defined with the keyword AS.

Elements with the type CHAR can have a maximum of 1333 characters. Elements with the type LRAW or LCHR must be at the end of the view. Only one such element is allowed per view. Furthermore, a field of type INT2 or INT4 must stand directly in front of such an element, representing the maximum length of the element.

Example

SELECT list with all possible elements.

Addition 1

... @element_annot ...

Effect

Specifies annotations for the element. The annotations must be specified before the element using @element_annot. All possible element annotations are listed in topic element annotations.

Notes

  • An annotation can be used to assign further technical and semantic attributes to an element for evaluation by the ABAP runtime framework. Framework-specific annotations can be used to give the element specific semantic attributes that are evaluated by other SAP frameworks.
  • With respect to the element annotations, publications of a CDS association association are handled like any regular element. When a CDS association defined in a different CDS view is exposed, the annotations of preceding publications are inherited when annotations are evaluated using the class CL_DD_DDL_ANNOTATION_SERVICE.

Addition 2

... KEY

Effect

KEY is used to define the current element as a key element of the current CDS view entity. All key elements must be placed without gaps at the start of the SELECT list.

Apart from that, the key elements of the CDS entity are mainly used to document the semantics of the data model. The addition KEY doesn't have any effect when the CDS view entity is activated and when other accesses are performed during program executions.

A CDS view entity without any composition or to-parent association can be defined without any key fields.

If the CDS view entity defines any composition or to-parent association, then it must contain at least one key field at the start of the SELECT list.

Example

The following CDS view entity defines two elements as key elements:

Since those are not the same as the key fields of the underlying database table SPFLI, the result set of the view can contain duplicate entries in respect to the key elements. Program DEMO_CDS_ENITITY_KEY shows the result of an ABAP SQL access to the view. The key elements are evaluated by the addition ORDER BY PRIMARY KEY, but apart from that, the key elements have no effect. When trying to select into a hashed table that uses the key elements for its unique key, a runtime error will occur most probably.

Addition 3

... AS alias

Effect

Defines an alternative element name for the current element. The alternative element name replaces the actual name of the element from the data source data_source. The alternative element name must comply with the general naming rules for names:

Alternative element names can be used in the current CDS view entity to grant unique names for identically named elements from different entities of the data source. When the current CDS view entity is accessed, the alternative element names must be used instead of the actual name. Alternative element names cannot be used within the view entity, with one exception: alternative element names can be specified after $projection in the ON condition of a CDS association.

Note

In particular, an alternative element name cannot be used as the operand of an expression.






CL_GUI_FRONTEND_SERVICES - Frontend Services   General Data in Customer Master  
This documentation is copyright by SAP AG.

Length: 17097 Date: 20240426 Time: 143844     sap01-206 ( 191 ms )