Ansicht
Dokumentation

ABENCDS_EXTEND_VIEW_ENTITY - CDS EXTEND VIEW ENTITY

ABENCDS_EXTEND_VIEW_ENTITY - CDS EXTEND VIEW ENTITY

BAL Application Log Documentation   CPI1466 during Backup  
This documentation is copyright by SAP AG.
SAP E-Book

- EXTEND VIEW ENTITY


EXTEND VIEW ENTITY cds_view_entity $| projection_view
       WITH
            $[association1
             association2 ...$]
            { select_list_extension }
            $[GROUP BY field1, field2, ...  $]
            $[ EXCEPT $| INTERSECT $| UNION $[ALL$]  { ... }$] $[;$]


Additions

1. ... GROUP BY field1, field2, ...

2. ... EXCEPT$|INTERSECT$|UNION $[ALL$] { ... }

Effect

Extends an existing CDS view entity cds_view_entity or an existing CDS projection view projection_view using a CDS view entity extension in the CDS DDL. An existing CDS view can have one or more CDS view entity extensions.

As a prerequisite for the enhancement of the CDS entity with the statement EXTEND VIEW ENTITY, the elements of the annotation array AbapCatalog.viewEnhancementCategory[ ] must be specified accordingly in its definition with DEFINE VIEW ENTITY:

  • By default or if only the value #PROJECTION_LIST is specified, views without aggregate expressions in the SELECT list and without a set-operator clause can be extended.
  • In order to extend views that have aggregate expressions in the SELECT list, the annotation array must contain the value #GROUP_BY alongside #PROJECTION_LIST.
  • In order to extend views that contain set-operator clauses, the annotation array must contain the value #UNION alongside #PROJECTION_LIST.
The annotation array value #UNION allows extensions not only for union views, but for views including any set operator (also EXCEPT and INTERSECT). The annotation array value #UNION is a known misnomer.
  • If the annotation array contains the value #NONE, the view cannot be extended.

Additionally, the annotation AbapCatalog.extensibility.extensible must not be set to false.

Components of a View Entity Extension

View entity extensions can make additions to the original view, but they can't modify, overwrite, or delete elements from the original view. The following components are possible in a CDS view entity extension:

  • New associations association1, association2 can be defined and exposed in the CDS view entity extension. The same rules apply that are described in topic CDS DDL - CDS view entity, ASSOCIATION.
It is not allowed to define new CDS to-parent associations in a view entity extension. New CDS composition associations are allowed under the condition that the composition target is also defined as composition child and has the required to-parent association.
  • Each appended element must have a unique name. If an appended element already occurs in the existing SELECT list or in a different extension, the element must be given an alternative element name using AS.

  • CDS view entity extensions themselves cannot be extended.
  • It is not possible to specify new input parameters in a view entity extension.
  • No addition ROOT can be specified in the statement EXTEND VIEW ENTITY to transform a regular view to a root entity.
  • An appended field cannot be defined as a KEY field.
  • In a view entity extension, header annotations are not supported. That means that no annotations are allowed in front of the statement EXTEND VIEW ENTITY.
  • For views that have an element of data type LRAW or LCHR in the SELECT list, no view extension is possible and the annotation AbapCatalog.viewEnhancementCategory[#NONE] is enforced. The reason is that elements of data types LRAW or LCHR must always be in the last position of the SELECT list.
  • CDS view entity extensions can't append fields of CDS projection views, CDS custom entities, or CDS abstract entities to a CDS view entity. Fields of CDS projection views, CDS abstract entities, or CDS custom entities can - generally - not be used in path expressions and this also holds true for path expressions in CDS view entity extensions.
This is not valid:
extend view entity MyExtension
  with {
    _assocToAbstract.field1   as Alias1
    _assocToCustom.field2     as Alias2
    _assocToProjection.field3 as Alias3
        }

Example

The following CDS view entity extension

adds two view fields to the existing CDS view entity

The program DEMO_CDS_VIEW_EXTENSION_VE uses the statement SELECT to access the enhanced view entity.

Addition 1

... GROUP BY field1, field2, ...

Effect

This addition must be specified if elements not defined using aggregate expressions are added to a view with aggregate expressions. These elements must be specified after GROUP BY and they extend the GROUP-BY clause of the original view. With respect to the extended view, the extended GROUP-BY clause must follow the general rules for a GROUP-BY clause.

As a prerequisite, the definition of the original view must contain at least one aggregate expression in its SELECT list.

Note

Extensions of a view with aggregate expressions require it to contain the annotation array viewEnhancementCategory[ ] with the values #PROJECTION and #GROUP_BY.

Example

The following CDS view entity extension

extends the existing CDS view entity

A database field connid and an aggregate expression sum(sflight.paymentsum) are added to the SELECT list. Accordingly, the addition GROUP BY must be used to add the database field to the GROUP-BY clause of the original view.

Addition 2

... EXCEPT $| INTERSECT $| UNION $[ALL$]

Effect

This addition must be specified when a view entity with a set operator ( EXCEPT, INTERSECT, or UNION) is extended. A corresponding addition ( EXCEPT, INTERSECT, or UNION) must be specified for each clause of the original view. The curly brackets can contain elements that extend the SELECT list of the associated set-operator clause of the original view. As specified by the SELECT list extended using select_list_extension, the set-operator clauses must be extended so that the rules for set-operator clauses are not broken in the extended view.

The addition ALL is available only for UNION views and it must be specified each time it is specified in the associated UNION clause of the original view.

As a prerequisite, the original view must have a set-operator clause.

Note

Extensions of a view with set-operator clauses require it to contain the annotation array viewEnhancementCategory[ ] with the values#PROJECTION_LIST and #UNION.

Example

The following CDS view entity extension

extends the existing CDS view

The original view entity has two UNION clauses represented using corresponding UNION additions in the definition of the CDS view entity extension. Two elements with matching types are added to the three SELECT lists of the original view.






Fill RESBD Structure from EBP Component Structure   Fill RESBD Structure from EBP Component Structure  
This documentation is copyright by SAP AG.

Length: 17815 Date: 20240416 Time: 091938     sap01-206 ( 211 ms )