SAP CDS PROJ VIEW ELEMENT



Get Example source ABAP code based on a different SAP table
  


• KEY ABAP_CDS_TRANS_QUERY
• LOCALIZED ABAP_CDS_TRANS_QUERY

ABAP_CDS_DDL - proj_element, Transactional Query

ABAP_SYNTAX
... $[@element_annot1$]
$[@element_annot2$]
...
${$[KEY$] ${proj_element $[AS alias$]$}
$| ${ expose_assoc $[AS alias$]$}
$| ${path_expr .element $[AS alias$]$[: LOCALIZED$]$}
$| ${cast_expr AS alias$}$}
$|${$[VIRTUAL elem_name : typing$]$}

ABAP Addition
1 ... KEY
2 ... AS alias
3 ... LOCALIZED
4 ... VIRTUAL

What does it do?
Defines which elements of the projected entity are part of the CDS projection view. Only elements from the projected entity can be specified as projected element.
The rules for propagation of element annotations in CDS projection views apply.
proj_element exposes an element from the projected entity. AS can be used to define an alternative element name alias. ABAP_NOTE In transactional projection views, an element from the projected entity can be exposed multiple times with different alias names.
expose_assoc exposes a CDS association, a CDS composition, or a CDS to-parent association from the projected entity. Exposed associations can be redirected to a new target when the association target is also projected. The keyword REDIRECTED TO is introduced in topic CDS DDL - CDS Projection View, expose_assoc. All elements included in the ON clause of an exposed CDS association must also be included in the projection list of the CDS projection view.
path_expr.element exposes an element of an association target of the projected 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. The keyword LOCALIZED can be used to display text elements in the user's logon language. All associations that are part of the path expression must be filtered to 1. For details, see the topic about path expressions in CDS projection views.
Cast expressions cast_expr are available in a reduced way:
The target data type can be specified as CDS simple type or as DDIC data element. Specifying a built-in ABAP Dictionary data type is not possible.
The addition PRESERVING TYPE is mandatory and must be used.
That means that type conversions are not supported in CDS projection views and cast expressions can only be used to derive semantic information.

ABAP_EXAMPLE_VX5
The following CDS projection view DEMO_SALES_PV_SO_I_LIST is a projection of the CDS view DEMO_SALES_CDS_SO_I. It contains details about a sales order item.
DDLS DEMO_SALES_PV_SO_I_LIST
ABAP_EXAMPLE_END

ABAP Addition

What does it do?
The keyword KEY is used to define the current element as a key element of the CDS projection view . A CDS projection view must define exactly the same key elements in the same order as key elements as the underlying projected entity.