ABAP Keyword Documentation → ABAP - Dictionary → ABAP CDS in ABAP Dictionary → ABAP CDS - Data Definitions → ABAP CDS - DDL for Data Definitions → ABAP CDS - DEFINE VIEW
ABAP CDS - DEFINE VIEW, view_annot
Other versions:
7.31 | 7.40 | 7.54
Syntax
... @annotation ...
Effect
Specifies an annotation annotation as a view annotation in the definition of a CDS view in front of the statement DEFINE VIEW. The character @ must be placed directly in front of the name annotation of the annotation. The annotation should be defined as a CDS object in a CDS annotation definition and the annotation definition annotation @Scope should be specified here using the value #VIEW.
The first column of the table displays the (possibly structured) name annotation of an ABAP annotation and the second column displays its meaning. The third column shows the possible annotation values. The fourth column shows the value set implicitly for the annotation value if the annotation is not used explicitly. The fifth column displays the default value set implicitly for value in accordance with the annotation definition if the annotation is specified without a value. If nothing is specified for the annotation value, the annotation should be specified without a value. INCLUDE ABENCDS_GENERAL_COMP_ANNOT OBJECT DOKU ID SD
Note
Alongside the view annotations shown here, the globally valid entity annotations can also be specified for a view.
AbapCatalog Annotations
Technical settings of a CDS view.
Annotation | Meaning | Annotation Values | Default Value if Not Used | Default Value if Used Without Value |
---|---|---|---|---|
AbapCatalog.buffering.status | Activates and deactivates table buffering for the CDS view | #ACTIVE: table buffering active |
||
#SWITCHED_OFF: table buffering allowed but not active |
||||
#NOT_ALLOWED: table buffering not allowed |
#SWITCHED_OFF | #SWITCHED_OFF | ||
AbapCatalog.buffering.type | Buffering type in table buffering | #SINGLE: Single records |
||
#GENERIC: Generic area |
||||
#FULL: Full |
||||
#NONE: None |
#NONE | #NONE | ||
AbapCatalog.buffering.numberOfKeyFields | Number of key elements in table buffering of generic areas | Number between 0 and k-1, where k is the number of key elements | 0 | 0 |
AbapCatalog.compiler.compareFilter | Defines the evaluation of filter conditions in path expressions of the CDS view | true: The filter conditions of CDS associations occurring morethan once in path expressions are compared and, if they match, the associated join expression is createdonly once. |
||
false: For each CDS association with a filter condition, a separate join expression is created and evaluated. |
false | true | ||
AbapCatalog.dbHints[ ].dbSystem | Obsolete: Database system for which adatabase hint is specified (evaluated usingSADL). Consumption.dbHintsCalculatedBy should be used instead. |
#ADA: SAP MaxDB |
||
#DB2: IBM DB2 |
||||
#DB4: IBM DB2 for AS/400 |
||||
#DB6: IBM DB2 UDB |
||||
#INF: Informix |
||||
#MSS: Microsoft SQL Server |
||||
#ORA: Oracle DB |
||||
#HDB: SAP HANA database |
||||
#ASE: Sybase ASE |
||||
#ALL: all database systems |
- | - | ||
AbapCatalog.dbHints[ ].hint | Obsolete: Database hint (evaluated usingSADL). Consumption.dbHints[] should be used instead. |
Platform-dependent database hint | - | - |
AbapCatalog.preserveKey | Specifies the definition of the key fields in the CDS database view of the CDS view. | true: The key fields of the CDS database view are defined as dictatedby the addition KEY. |
||
false: The key fields of the CDS database view are determinedas for database views in ABAP Dictionary, regardless of the addition KEY. |
false | true | ||
AbapCatalog.sqlViewName | Name of the CDS database view of the CDS view | Character string with a maximum of 16 characters consisting of letters, numbers and underscores and that starts with anamespace prefix. | - | - |
AbapCatalog.viewEnhancementCategory[ ] | Specifies how the CDS view is extended using CDS view enhancements. A comma-separated list of values can be specified in the square brackets of theannotation array. | #PROJECTION_LIST: Extensions of the SELECTlist and additional CDS associations are allowed; extensions of CDS views whose SELECT lists containaggregate expressions or have a UNION clause must be permitted using further values |
||
#GROUP_BY: Aggregated or non-aggregated elements are allowed to be added to a SELECT list withaggregated expressions and the associatedextensions of the of the GROUP-BYclause are also permitted; can only be specified together with #PROJECTION_LIST |
||||
#UNION: Extensions of the SELECTlist of a CDS view with a UNIONclause are allowed; can only be specified together with #PROJECTION_LIST |
||||
#NONE: No extensions allowed; cannot be specified together with other values |
#PROJECTION_LIST | #PROJECTION_LIST |
Notes
- Each definition of a CDS view must contain the ABAP annotation AbapCatalog.sqlViewName, which defines the name of the CDS database view in ABAP Dictionary.
- The name given to the database view can no longer be changed after the CDS view is transported into a follow-on system.
- In the annotation array AbapCatalog.viewEnhancementCategory[ ], #GROUP_BY and #UNION can only be specified together with the default value #PROJECTION_LIST. The value #NONE excludes any other values.
- Extensions of a view with aggregate expressions or with a UNION clause modify the cardinality of the results set. This means that these extensions must have special permission in the view to enable consumers of the view to handle any changes to cardinalities.
- It is advisable to use the annotation AbapCatalog.compiler.compareFilter with the value true. ADT suggests this when a new CDS view is created.
- The framework-specific annotation @Consumption.dbHints replaces the ABAP annotation @AbapCatalog.dbHints and makes it obsolete. The ABAP annotation is evaluated by frameworks such as SADL and not by the ABAP runtime environment.
Example
Activates table buffering with single record buffering for the CDS view business_partner.
@AbapCatalog.buffering.status: #ACTIVE
@AbapCatalog.buffering.type: #SINGLE
define view business_partner as
select from snwd_bpa
{ key snwd_bpa.bp_id as id,
snwd_bpa.bp_role as role,
snwd_bpa.company_name,
snwd_bpa.phone_number }
Example
For the CDS view business_partner, activates table buffering for a generic area and a key element.
@AbapCatalog.buffering.status: #ACTIVE
@AbapCatalog.buffering.type: #GENERIC
@AbapCatalog.buffering.numberOfKeyFields: 1
define view business_partner as
select from snwd_bpa
{ key snwd_bpa.bp_id as id,
snwd_bpa.bp_role as role,
snwd_bpa.company_name,
snwd_bpa.phone_number }
AccessControl Annotations
Defines access control for the CDS view.
Annotation | Meaning | Annotation Values | Default Value if Not Used | Default Value if Used Without Value |
---|---|---|---|---|
AccessControl.authorizationCheck | Defines implicit access control when ABAP SQL is used to access the CDS view | #CHECK: If ABAP SQL is used to access the view,access control is performed implicitly if aCDS role is assigned to theview. If there is no role for the view, a syntax check warning occurs. |
||
#NOT_REQUIRED: Like #CHECK, but there is no syntax check warning. |
||||
#NOT_ALLOWED: Noaccess control is performed. This produces a syntaxcheck warning in the DCL source code of a role for the view. |
||||
#PRIVILEGED_ONLY: Privileged CDS association (evaluated bySADL). |
#CHECK | #CHECK |
Notes
- Value #NOT_REQUIRED is recommended for CDS views that no access control is provided for when they are created, but which roles can be defined for later on.
- The value #NOT_ALLOWED switches implicit access control off when the
CDS view is accessed in ABAP SQL. The addition
WITH PRIVILEGED ACCESS can be used in the
FROM clause to switch access control off for views not annotated with this annotation. In the case of views too, the authorization check with the addition
WITH PRIVILEGED ACCESS
must be disabled in updates in ABAP SQL statements. If not, a runtime error occurs.
- CDS access control
does not work for cross-client access. This is why in ABAP SQL, the addition
USING
and the obsolete additionCLIENT SPECIFIED
can only be used when accessing CDS entities where access control is disabled. It is recommended that the annotation AccessControl.authorizationCheck:#NOT_ALLOWED is only specified for CDS views that are subject to cross-client access.
- The annotation AccessControl has further framework-specific subannotations.
ClientDependent Annotations (Obsolete)
Defines client handling for the CDS view (obsolete).
Annotation | Meaning | Annotation Values | Default Value if Not Used | Default Value if Used Without Value |
---|---|---|---|---|
ClientDependent | Defines client handling when ABAP SQL is used to access the CDS view (obsolete). | true: The CDS view is client-specific. The view fields of theCDS entity do not cover a client column, from the perspective of an ABAP program. When accessed using SELECT ,implicit client handling is applied. |
||
false: The CDS view is a cross-client view. Noimplicit client handling is applied. |
- | true |
Notes
- The obsolete annotation @ClientDependent is replaced by the annotations @ClientHandling.type and @ClientHandling.algorithm.
- The obsolete annotation @ClientDependent does not have a default value if it is not used. If neither of the annotations @ClientDependent or @ClientHandling are specified, the default values of the @ClientHandling annotations apply.
- The obsolete annotation @ClientDependent cannot be specified together with the annotation @ClientHandling.
ClientHandling Annotations
Defines client handling for the CDS view.
Annotation | Meaning | Annotation Values | Default Value if Not Used | Default Value if Used Without Value |
---|---|---|---|---|
ClientHandling.type | Defines the client dependency when ABAP SQL is used to access the CDS view. | #CLIENT_DEPENDENT: The CDS view is client-specific. When accessed using SELECT ,implicit client handling is applied. |
||
#CLIENT_INDEPENDENT: The CDS view is a cross-client function. When accessed using SELECT , noimplicit client handling is applied. |
||||
#INHERITED: The client dependency of the CDS view is determined by the data sources used. If a data source is client-specific, the CDS view is too. |
#INHERITED | #INHERITED | ||
ClientHandling.algorithm | Defines client handling when ABAP SQL is used to access the CDS view. | #NONE: No implicit client handling takes place. |
||
#AUTOMATED: The joins of the CDS view are modified implicitly. |
||||
#SESSION_VARIABLE: The joins of the CDS view are modified implicitly and the session variable $session.client is used implicitly to improve performance. |
#AUTOMATED | #AUTOMATED |
Note
An annotation @ClientHandling cannot be specified together with the obsolete annotation @ClientDependent.
DataAging Annotations
Defines data aging for the CDS view.
Annotation | Meaning | Annotation Values | Default Value if Not Used | Default Value if Used Without Value |
---|---|---|---|---|
DataAging.noAgingRestriction | Defines how data aging is respected on aSAP HANA database when the CDS view is accessed using ABAP SQL. | true: ABAP SQL reads all data |
||
false: ABAP SQL reads current data only |
false | true |
Example
When the CDS view sales_order_12 is accessed, all data is read on SAP HANA databasesand not just data flagged as "HOT" in the database table snwd_so.
@DataAging.noAgingRestriction:true
define view sales_order_2012 as
select from snwd_so
{ key snwd_so.so_id,
snwd_so.buyer_guid as customer_guid }
where snwd_so.created_at >= 20120101000000.0
and snwd_so.created_at < 20130101000000.0;
Metadata Annotations
Defines the handling of metadata from the CDS view.
Annotation | Meaning | Annotation Values | Default Value if Not Used | Default Value if Used Without Value |
---|---|---|---|---|
Metadata.ignorePropagatedAnnotations | Defines whether analysis of annotations is possible using the annotation API CL_DD_DDL_ANNOTATION_SERVICE. | true: Only direct and derived annotations of the current CDS entityare respected. |
||
false: Inherited annotations of CDS entities used are also respected. |
false | true |
ObjectModel Annotations
...
Annotation | Meaning | Annotation Values | Default Value if Not Used | Default Value if Used Without Value |
---|---|---|---|---|
ObjectModel.usageType.dataClass | ... | ...: ... |
||
...: ... |
... | ... | ||
ObjectModel.usageType.serviceQuality | ... | ...: ... |
||
...: ... |
... | ... | ||
ObjectModel.usageType.sizeCategory | ... | ...: ... |
||
...: ... |
... | ... |
...
Notes
- ...
- In addition to the ABAP annotations shown here, there are also framework-specific ObjectModel annotations.