SAP CDS SELECT LIST ENTRY V2



Get Example source ABAP code based on a different SAP table
  


• KEY ABAP_CDS_SELECT_ELEM
• AS ABAP_CDS_SELECT_ELEM

ABAP_CDS_DDL - CDS View Entity, SELECT, element

ABAP_SYNTAX
... ${ $[@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 $}
$| ${ SQL-based scalar function
AS alias $}
$| ${ reuse_exp AS alias $}
$| ${ case_expr AS alias $}
$| ${ cast_expr AS alias $}
...
$}

What does it do?
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.

ABAP Addition
1 ... @element_annot ...
2 ... KEY
3 ... AS alias

What does it do?
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.
expose_assoc exposes a CDS association , a CDS composition, or a CDS to-parent association using a path expression. If a CDS association with a filter condition cds_cond is exposed, an alternative element name alias with AS must be defined. Otherwise, an alternative element name can be defined.
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.
An SQL-based scalar function can be defined as an element. An alias name is mandatory.
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.

ABAP_EXAMPLE_VX5
SELECT list with all possible elements.
DDLS DEMO_SALES_CDS_SALES_ORDER_VE
ABAP_EXAMPLE_END

ABAP Addition

What does it do?
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.



Latest notes:

An annotation can be used to assign further technical and semantic properties to an element for evaluation by the ABAP runtime framework. Framework-specific annotations can be used to give the element specific semantic properties that are evaluated by other SAP frameworks.
NON_V5_HINTS
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 prec eding publications are inherited when annotations are evaluated using the class CL_DD_DDL_ANNOTATION_SERVICE.
ABAP_HINT_END

ABAP Addition

What does it do?
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.