SAP NetWeaver AS ABAP Release 750, ©Copyright 2016 SAP AG. All rights reserved.
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 elements of the specified extension list select_list_extension as view fields
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 actual name cds_view_extension of the CDS view extension is specified after the keywords EXTEND VIEW. This name follows the same rules as the name of an
append view, but can have up to 30 characters.
- The name CDS_APPEND_VIEW for a classic
append view must be specified in quotation marks after the
annotation @AbapCatalog.sqlViewAppendName
created when the CDS view extension was activated. This name is subject to the same rules as the name of a classic
view in ABAP Dictionary. The new append view extends the
CDS database view
of the extended CDS view. The name given to the append view can no longer be changed after the CDS view is transported into a follow-on system.
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:
- Path expressions for various associations and for associations of the extended CDS view
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
- Every CDS view extension has its own CDS source code. The CDS source code in a CDS view extension is edited in a different editor from the CDS source code of a
CDS view. The ADT documentation describes how these types of source code are created.
- An existing CDS view can be extended using multiple CDS view extensions.
- The name of the new append view and of the actual CDS view extension should be located in the customer
namespace (or in the namespace of a partner or special development) to protect it against being overwritten by upgrades or new releases.
- Currently it is not possible to define extension categories for CDS views. The following restrictions apply for this reason:
- CDS views have the property can be extended in any way with respect to the
extension category of structures. The consequences of this must be respected when extending a CDS view.
- Functional extensions, such as adding aggregate functions and the associated changes to the
GROUP-BY clause or extensions to join expressions or other clauses, are not supported.
- The attributes of a CDS view defined using annotations, such as switching on
SAP buffering, cannot currently be modified using extensions.
- It is advisable to contact SAP before extending CDS views from basis packages.
- The CDS source code of a CDS view extension does not need to have the same name as the CDS view extension entity, but it is advisable to use the name of the entity.
- After a piece of CDS source code is transported, the combination of its name and the name of the CDS view extension defined in it and its APPEND view is defined and can no longer be modified by being renamed.
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