Ansicht
Dokumentation

ABENCDS_VIEW_ANNO_V1 - CDS VIEW ANNO V1

ABENCDS_VIEW_ANNO_V1 - CDS VIEW ANNO V1

General Material Data   CPI1466 during Backup  
This documentation is copyright by SAP AG.
SAP E-Book

- DDIC-Based View, view_annot

... @annotation ...

Effect

Specifies an annotation annotation as a view annotation in the definition of a 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.

Note

Alongside the view annotations shown here, the globally valid entity annotations can also be specified for a CDS view.

AbapCatalog Annotations

Technical settings of a CDS view.
AbapCatalog.buffering.status,,Activates and deactivates table buffering for the CDS view,, #ACTIVE:\lbr table buffering active \lbr\lbr #SWITCHED_OFF:\lbr table buffering allowed but not active \lbr\lbr #NOT_ALLOWED:\lbr table buffering not allowed,, #SWITCHED_OFF,,#SWITCHED_OFF
AbapCatalog.buffering.type,,Buffering type in table buffering,, #SINGLE:\lbr Single records \lbr\lbr#GENERIC:\lbr Generic area \lbr\lbr#FULL:\lbr Full \lbr\lbr#NONE:\lbr 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.dataMaintenance,,Can be used to restrict data preview for a CDS view,, #RESTRICTED:\lbr Display allowed with restrictions \lbr\lbr#DISPLAY_ONLY:\lbr Display only. Data preview is allowed \lbr\lbr#NOT_ALLOWED:\lbr Display not allowed \lbr\lbr ,, #RESTRICTED,,-
AbapCatalog.compiler.compareFilter,,Defines the evaluation of filter conditions in path expressions of the CDS view,, true:\lbr The filter conditions of CDS associations occurring more than once in path expressions are compared and, if they match, the associated join expression is created only once. \lbr\lbr false:\lbr 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 a database hint is specified (evaluated using SADL). \lbr \lbr Consumption.dbHintsCalculatedBy should be used instead.,,#ADA:\lbr SAP MaxDB \lbr\lbr#DB2:\lbr IBM DB2 \lbr\lbr#DB4:\lbr IBM DB2 for AS/400 \lbr\lbr#DB6:\lbr IBM DB2 UDB \lbr\lbr #INF:\lbr Informix \lbr\lbr#MSS:\lbr Microsoft SQL Server \lbr\lbr#ORA:\lbr Oracle DB \lbr\lbr #HDB:\lbr SAP HANA database \lbr\lbr#ASE:\lbr Sybase ASE \lbr\lbr#ALL:\lbr all database systems,,-,,-
AbapCatalog.dbHints[ ].hint,,Obsolete: Database hint (evaluated using SADL). \lbr \lbr Consumption.dbHints[ ] should be used instead.,,Platform-dependent database hint,, -,,-
AbapCatalog.preserveKey,,Specifies the definition of the key fields in the CDS-managed DDIC view of the CDS view.,,true:\lbr The key fields of the CDS-managed DDIC view are defined as determined by the addition KEY. \lbr\lbrfalse:\lbr The key fields of the CDS-managed DDIC view are determined as for DDIC database views in ABAP Dictionary, regardless of the addition KEY.,,false,,true
AbapCatalog.sqlViewName,,Name of the CDS-managed DDIC view of the CDS view,,Character string with a maximum of 16 characters consisting of letters, numbers and underscores and that starts with a namespace prefix.,,-,,-
AbapCatalog.viewEnhancementCategory[ ],,Specifies how the CDS view is extended using CDS view extensions. A comma-separated list of values can be specified in the square brackets of the annotation array.,,#PROJECTION_LIST:\lbr Extensions of the SELECT list and additional CDS associations are allowed; extensions of CDS views whose SELECT lists contain aggregate expressions or have a UNION clause must be allowed using further values \lbr\lbr #GROUP_BY:\lbr Aggregated or non-aggregated elements are allowed to be added to a SELECT list with aggregated expressions and the associated extensions of the of the GROUP-BY clause are also allowed; can only be specified together with #PROJECTION_LIST \lbr\lbr#UNION:\lbr Extensions of the SELECT list of a CDS view with a UNION clause are allowed; can only be specified together with #PROJECTION_LIST \lbr\lbr#NONE:\lbr No extensions allowed; cannot be specified together with other values,, #PROJECTION_LIST,,#PROJECTION_LIST

Notes

  • The ABAP annotation AbapCatalog.sqlViewName is mandatory. It defines the name of the CDS-managed DDIC view in ABAP Dictionary.
  • The name given to the DDIC 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.
  • AbapCatalog.viewEnhancementCategory[#NONE] is mandatory for views that contain an element of data type LRAW or LCHR. The reason is that elements of data type LRAW or LCHR must always be in the last position in the SELECT list and therefore, no extensions are allowed.
  • Extensions of a view with aggregate expressions or with a UNION clause modify the cardinality of the result 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 annotation AbapCatalog.dataMaintenance defines whether the can be displayed or maintained by certain tools such as Data Preview in ABAP Development Tools (ADT). The annotation is evaluated by these tools. Restrictions imposed by that annotation are user-independent and they are evaluated before accessing the data. Additional restrictions imposed by CDS roles are evaluated during the actual data access, if this is done by.
  • The name AbapCatalog.sqlViewName is a bit misleading. The annotation does not define the SQL view of the database directly, but an intermediate DDIC view. The SQL view of the database is derived from the DDIC view.

Example

Example for the annotation AbapCatalog.compiler.compareFilter.

The following image shows the SQL statement that is generated on the database when the annotation AbapCatalog.compiler.compareFilter is set to true. Only one join expression is generated:

IMAGE @@ABDOC_TRUE.png@@501@@167@@

The following image shows the SQL statement that is generated on the database when the annotation AbapCatalog.compiler.compareFilter is set to false. Two join expressions are generated:

IMAGE @@ABDOC_FALSE.png@@485@@256@@

Example

Activates table buffering with single record buffering for the CDS view business_partner.

@AbapCatalog.sqlViewName:      'BPA_VW'
@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.sqlViewName:                 'BPA_VW'
@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.
AccessControl.authorizationCheck,,Defines implicit access control when is used to access the CDS view,,#CHECK:\lbr If is used to access the view, access control is performed implicitly if a CDS role is assigned to the view. If there is no role for the view, a syntax check warning occurs. \lbr\lbr #NOT_REQUIRED:\lbr Like #CHECK, but there is no syntax check warning. \lbr\lbr#NOT_ALLOWED:\lbr No access control is performed. This produces a syntax check warning in the DCL source code of a role for the view. \lbr\lbr#PRIVILEGED_ONLY:\lbr Privileged CDS association (evaluated by SADL).,, #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 disables implicit access control when the CDS view is accessed in . The addition WITH PRIVILEGED ACCESS can be used in the FROM clause to disable access control 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 client-independent access. This is why in , the addition USING and the obsolete addition CLIENT 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 client-independent access.

ClientDependent Annotations (Obsolete)

Defines client handling for the CDS view (obsolete).
ClientDependent,,Defines client handling when is used to access the CDS view (obsolete).,,true:\lbr The CDS view is client-dependent. The view fields of the CDS entity do not cover a client column, from the perspective of an ABAP program. When accessed using SELECT, implicit client handling is applied. \lbr\lbrfalse:\lbr The CDS view is a client-independent view. No implicit 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.
ClientHandling.type,,Defines the client dependency when is used to access the CDS view.,,#CLIENT_DEPENDENT:\lbr The CDS view is client-dependent. When accessed using SELECT, implicit client handling is applied. \lbr\lbr#CLIENT_INDEPENDENT:\lbr The CDS view is a client-independent function. When accessed using SELECT, no implicit client handling is applied. \lbr\lbr#INHERITED:\lbr The client dependency of the CDS view is determined by the data sources used. If a data source is client-dependent, the CDS view is too. ,,#INHERITED,,#INHERITED
ClientHandling.algorithm,,Defines client handling when is used to access the CDS view.,,#NONE:\lbr No implicit client handling takes place. \lbr\lbr#AUTOMATED:\lbr The joins of the CDS view are modified implicitly. \lbr\lbr #SESSION_VARIABLE:\lbr 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.
DataAging.noAgingRestriction,,Defines how data aging is respected on a SAP HANA database when the CDS view is accessed using . ,,true:\lbr reads all data \lbr\lbrfalse:\lbr reads current data only ,,false,,true

Example

In the following CDS view, data aging is disabled for the database table DAAG_SFLIGHT using the annotation@DataAging.noAgingRestriction:true.

When this view is accessed using , both old and current data is read.

To avoid loading all partitions, a filter dependency rule can be defined as follows. Here, the assumption is made that the temperature column _DATAAGING for outdated data has the same value as the column FLDATE.

DEFINE FILTER DEPENDENCY RULE demo_daag_sflight_rule
  ON daag_sflight
    IF { daag_sflight.fldate >= $1 }
      THEN { daag_sflight._dataaging >= $1 OR
             daag_sflight._dataaging =  '00000000' }

The SAP HANA database then adds the following additional selection condition to the WHERE condition of the shown SELECT statement implicitly:

AND daag_sflight~_dataaging >= '20160101'
    OR  daag_sflight~_dataaging =  '00000000'

This does not modify the result set of the query.

Metadata Annotations

Defines the handling of metadata from the CDS view.
Metadata.ignorePropagatedAnnotations,,Defines whether analysis of annotations is possible using the annotation API CL_DD_DDL_ANNOTATION_SERVICE.,, true:\lbr Only direct and derived annotations of the current CDS entity are respected. \lbr\lbr false:\lbr Inherited annotations of CDS entities used are also respected.,,false,,true

ObjectModel Annotations

The following subannotations of ObjectModel characterize CDS views with respect to their performance-relevant properties.
ObjectModel.usageType.dataClass,,Specifies the data category of the CDS view.,,A CDS view can be assigned to one of the following data categories: \lbr\lbr#TRANSACTIONAL: \lbr The CDS view delivers data written or modified in high volume transactions or in background transactions. \lbr\lbr #MASTER: \lbr The CDS view delivers master data. The master data is read in high volume transactions or background transactions, but not written or modified. \lbr\lbr #ORGANIZATIONAL: \lbr The CDS view delivers data that describes organizational structures and customer processes. \lbr\lbr#CUSTOMIZING: \lbr The CDS view delivers data that describes customizing data. \lbr\lbr #META: \lbr The CDS view delivers technical system configuration data or the structure of entities. \lbr\lbr#MIXED: \lbr The CDS view delivers data of mixed data categories.,,#MIXED,,#MIXED
ObjectModel.usageType.serviceQuality,,The quality of the service with respect to the performance that can be expected by the consumer of the CDS view.,,A CDS view can be assigned to one of the following quality categories: \lbr\lbr #A: \lbr The CDS view can be used for high volume transactions or for background transactions. \lbr\lbr#B: \lbr The CDS view can be used for transactions or for background transactions. \lbr\lbr #C: \lbr The CDS view can be used to query individual objects in transactions. \lbr\lbr #D: \lbr The CDS view can be used for analytical queries. \lbr\lbr #X: \lbr The CDS view is designed for special application cases, such as data migration. \lbr\lbr #P: \lbr The CDS view is used to structure hierarchies of CDS entities and must not be used outside of such a hierarchy.,,#X,,#X
ObjectModel.usageType.sizeCategory,,Specifies the size of the data volume that must be scanned to return the result. This usually corresponds to the largest underlying table.,,A CDS view can be assigned to one of the following size categories: \lbr\lbr #S: \lbr The expected size of the data volume that needs to be scanned is less than 1000. \lbr\lbr #M: \lbr The expected size of the data volume that needs to be scanned is less than 100,000. \lbr\lbr#L: \lbr The expected size of the data volume that needs to be scanned is less than 10,000,000. \lbr\lbr #XL: \lbr The expected size of the data volume that needs to be scanned is less than 100,000,000. \lbr\lbr#XXL: \lbr The expected size of the data volume that needs to be scanned is 100,000,000 or greater.,,#S,,#S

Notes

  • With the above subannotations of ObjectModel it can be documented for a view for which kind of application it is intended and which kind of data are to expected. This information is especially important in regards of performance that can be expected by the consumer of the view. For the quality categories annotated with ObjectModel.usageType.serviceQuality, the following rules apply:
  • A CDS view with the quality category A should access no more than three DDIC database tables, must not call any functions, must not aggregate a large number of table rows for direct access, and must not access DDIC database tables with mixed data categories. If the underlying tables are buffered, the CDS view should be buffered too. The runtime for reading a single line with a fully specified key must be less than 1 ms for selecting fields from a field list or 2 ms for selecting all fields with *.

  • A CDS view with the quality category B should access no more than five DDIC database tables, must not call any functions, must not aggregate a large number of table rows for direct access, and must not access DDIC database tables with mixed data categories. If the underlying tables are buffered, the CDS view should be buffered too. The runtime for reading a single line with a fully specified key must be less than 2 ms for fields from a field list or 5 ms for selecting all fields with *.

  • A CDS view with the quality category C should access no more than 15 DDIC database tables, must not aggregate a large number of table rows for direct access, and must not access DDIC database tables with mixed data categories. The runtime for reading a single line with a fully specified key must be less than 10 ms for fields from a field list or 20 ms for selecting all fields with *.

  • A CDS view with the quality category D should access no more than 100 DDIC database tables. The performance should be checked and monitored with realistic data by a test framework.

  • A CDS view with the quality category X can access more than 100 database tables. The performance must be checked and monitored with realistic data by a test framework.

  • A CDS view with the quality category P is not intended for usage in business applications. Performance checks by a test framework are not required.

  • For all quality categories, the subannotations sizeCategory and dataClass should be specified. Only for quality category P, they do not need to be specified.

These rules can be checked in the ABAP Test Cockpit (ATC) by tests delivered by SAP.
  • Generally, a CDS view used in an application should not access more than 100 DDIC database tables and should have a quality category between A and D.





CPI1466 during Backup   ROGBILLS - Synchronize billing plans  
This documentation is copyright by SAP AG.

Length: 42417 Date: 20240416 Time: 183908     sap01-206 ( 550 ms )