Get Example source ABAP code based on a different SAP table
• REDIRECTED TO ABAP_CDS_PROJ_VIEW • REDIRECTED TO COMPOSITION CHILD ABAP_CDS_PROJ_VIEW • REDIRECTED TO PARENT ABAP_CDS_PROJ_VIEW
ABAP_CDS_DDL - redirected>, Transactional Query
ABAP_SYNTAX ... REDIRECTED TO proj_view $| REDIRECTED TO COMPOSITION CHILD proj_view $| REDIRECTED TO PARENT proj_view>
ABAP_VARIANTS: 1 ... REDIRECTED TO proj_view > 2 ... REDIRECTED TO COMPOSITION CHILD proj view> 3 ... REDIRECTED TO PARENT proj view>
What does it do? Redirects a CDS association>, a CDS composition>, or a CDS to-parent association> of the projected entity> in a CDS projection view> to a new association target. As a prerequisite, the original association target must also have a CDS projection view. Redirection using the keyword REDIRECTED TO $[...$]> means to direct an association to a new association target, which is also a CDS projection view, in this way moving the complete data model to the projection layer. With redirection, a specialized CDS association can lose its specialization and become a simple CDS association. This means that you can redirect a CDS composition or a CDS to-parent association with the keyword REDIRECTED TO> and then it is exposed as a simple CDS association. The other way around is not possible - a simple CDS association cannot be specialized. Thus, you cannot use the addition REDIRECTED TO COMPOSITION CHILD> or REDIRECTED TO PARENT> to redirect a simple CDS association.
ABAP_EXAMPLE_VX5 The projection view DEMO_SALES_PV_SO> > is based on the CDS view DEMO_SALES_CDS_SO>>. It replaces the association targets> of the associations with other CDS projection views where required. DDLS DEMO_SALES_PV_SO ABAP_EXAMPLE_END
ABAP_EXAMPLE_ABEXA The executable example Exposing Associations> accesses the CDS projection view shown above, reads all fields and returns the result. ABAP_EXAMPLE_END
ABAP_VARIANT_1 ... REDIRECTED TO proj_view >
What does it do? Redirects a CDS association> exposed in a CDS projection view to a new association target>. The following applies to the redirection of a CDS association:
Can be used to redirect simple CDS associations, CDS compositions, or to-parent associations. ABAP_NOTE When the keyword REDIRECTED TO> is used on specialized CDS associations (CDS compositions > or CDS to-parent associations >), they become non-specialized and are handled as CDS associations. Compositions and to-parent associations which are projected in this way never define compositions and to-parent associations in the projection view.
The target of the redirection proj_view> must be a projection view based on the original target of the association.
The target of the redirection proj_view> can be the CDS projection view proj_view> itself only if the projected CDS association is a self association>.
The target of the redirection REDIRECTED TO> cannot be specified using a path expression>.
The CDS projection view proj_view> can be used multiple times as the redirection target of the projected CDS associations in the CDS projection view proj_view>. The following syntax is valid: _Assoc1: REDIRECTED TO proj_view, _Assoc2: REDIRECTED TO proj_view>
ABAP_VARIANT_2 ... REDIRECTED TO COMPOSITION CHILD proj_view>
What does it do? Redirects a CDS composition> exposed in a CDS projection view to a new association target>. With the addition REDIRECTED TO COMPOSITION CHILD>, the special characteristics of a CDS composition are kept. The following applies to the redirection of a CDS composition:
The CDS association redirected using the addition REDIRECTED TO COMPOSITION CHILD> must be a CDS composition.
The target of the redirection REDIRECTED TO COMPOSITION CHILD> must be the projection of the original target of the association. Therefore, the target cannot be a root projection view.
The target of the redirection REDIRECTED TO COMPOSITION CHILD> cannot be specified using a path expression>.
The target of REDIRECTED TO COMPOSITION CHILD> cannot be the CDS projection view proj_view> itself. A self association> is not possible.
The redirection target proj_view> must project exactly one to-parent association to its composition parent. This to-parent association must exist before the composition can be projected in the projection view.
The redirection target proj_view> can be used only once in a CDS composition and multiple times in CDS associations. This is demonstrated in the following simplified example:
This is valid _Assoc1: REDIRECTED TO COMPOSITION CHILD proj_view, _Assoc2: REDIRECTED TO proj_view>
This is not valid _Assoc1: REDIRECTED TO COMPOSITION CHILD proj_view, _Assoc2: REDIRECTED TO PARENT$|${COMPOSITION CHILD$} proj_view>
ABAP_VARIANT_3 ... REDIRECTED TO PARENT proj_view>
What does it do? Redirects a to-parent association > in a CDS projection view to a new association target>. With the addition REDIRECTED TO PARENT>, the special characteristics of a CDS to-parent association are kept. The following applies to the redirection of a CDS to-parent association:
The CDS association to_parent_assoc> projected with this syntax must be defined as a CDS to-parent association in the underlying CDS view.
The target of the redirection REDIRECTED TO PARENT> should be the projection of the original target of the to-parent association.
The target of the redirection REDIRECTED TO PARENT> cannot be specified using a path expression>.
The addition REDIRECTED TO PARENT> can be used no more than once in the definition of a CDS projection view. This means that a CDS projection view can have no more than one parent entity.
The redirection target cannot be the CDS projection view proj_view> itself. A self association > is not possible.
The redirection target proj_view> can be used only once in a CDS to-parent association and multiple times in CDS associations. This is demonstrated in the following simplified example:
This is valid _Assoc1: REDIRECTED TO PARENT proj_view, _Assoc2: REDIRECTED TO proj_view>
This is not valid _Assoc1: REDIRECTED TO PARENT proj_view, _Assoc2: REDIRECTED TO PARENT$|${COMPOSITION CHILD$} proj_view>