ABAP - Keyword Documentation →  ABAP - Dictionary →  ABAP CDS in ABAP Dictionary →  ABAP CDS - Data Definitions →  ABAP CDS - DDL Statements → 

ABAP CDS - EXTEND VIEW

Syntax

@AbapCatalog.sqlViewAppendName: 'CDS_APPEND_VIEW'
[@extension_annot1]
[@extension_annot2]
...
EXTEND VIEW cds_entity WITH cds_view_extension
            [association1 association2 ...]
            { select_list_extension } [;]

Effect

Extends an existing CDS view cds_entity using a CDS view extension cds_view_extension in CDS source code. The extension adds the following to the SELECT list of the available view without making changes:

The annotation AbapCatalog.sqlViewAppendName must be specified before the view extension itself is defined using EXTEND VIEW. Further annotations extension_annot1, extension_annot2, ... can also be specified. This is optional.

Two ABAP Dictionary objects are created for a CDS view extension that is defined using EXTEND VIEW. A name must be specified for each of the two objects:

The extended CDS view must be specified under the name of its CDS entity. The name of the CDS database view cannot be specified here. It is possible to access all fields of the data sources used in the extended CDS view in the extension list select_list_extension. The list can have all elements of a SELECT list, except aggregate expressions. You can also specify the following:

If an appended element already occurs in the existing SELECT list or if a different extension occurs, it must be given an alternative element name using AS. An appended field cannot be defined as a key field using KEY.

The following CDS views cannot currently be extended:

CDS view extensions themselves cannot be extended.

Notes

Example

The following CDS view extension:

@AbapCatalog.sqlViewAppendName: 'DEMO_CDS_EXTENS'
extend view demo_cds_original_view with demo_cds_view_extension
  { spfli.distance,
    spfli.distid as unit };

adds two view fields to the existing CDS view:

@AbapCatalog.sqlViewName: 'DEMO_CDS_ORIG'
@AccessControl.authorizationCheck: #NOT_REQUIRED
define view demo_cds_original_view
  as select from spfli
            join scarr on scarr.carrid = spfli.carrid
     { key scarr.carrname as carrier,
       key spfli.connid   as flight,
       spfli.cityfrom     as departure,  
       spfli.cityto       as destination };

The classic append view DEMO_CDS_EXTENS is created in ABAP Dictionary. The program DEMO_CDS_VIEW_EXTENSION uses the statement SELECT to access the extended view and also displays the components of the dictionary structures in question.



Continue
ABAP CDS - EXTEND VIEW, extension_annot