Skip to content

ABAP Keyword Documentation →  ABAP Dictionary →  ABAP CDS in ABAP Dictionary 

ABAP CDS - Views

A CDS is defined for existing database tables and any other views or CDS views in ABAP Dictionary using the statement DEFINE VIEW in the DDL in ABAP Core Data Services (CDS). This is done in CDS source code in the ABAP Development Tools (ADT).. Every CDS view has its own CDS source code. Two objects are created in ABAP Dictionary for every CDS view:

The CDS database view is a read-only classic database view in ABAP Dictionary. The name CDS_DB_VIEW of this view is defined in the definition of a CDS view in the CDS annotation @AbapCatalog.sqlViewName. The ABAP Dictionary tool in ABAP Workbench (SE11) can display a CDS database view, but it cannot be edited here. When the view is activated, the corresponding SQL view is created with the same name.
As a data type in ABAP Dictionary, the CDS database view represents (like all classic database views) a flat structure with the elements of the CDS view as components.
  • In ABAP, the CDS database view can (using its name CDS_DB_VIEW) be used wherever database tables or classic database views can also be specified, such as after the TYPE addition, in reading Open SQL statements, but also in Native SQL or after the TABLES statement. An exception to this are Open SQL writes.
  • In ABAP Dictionary, the CDS database view can also be used like any classic structure, such as the type of a substructure, as an include structure, or as the row type of a table type.
The CDS entity is the actual CDS view. It covers the CDS database view and makes other attributes possible, such as authorization checks defined in CDS. The name of this view, cds_entity, is defined in the definition of a CDS view after DEFINE VIEW. The definition of the CDS entity occurs only as CDS source code. The ABAP Dictionary tool in ABAP Workbench (SE11) does not recognize the CDS entity.
As a data type in ABAP Dictionary, the CDS entity represents a structured type with the elements of the CDS view as components.
  • In ABAP, the CDS entity can be specified after the TYPE addition using its name cds_entity. This lets it reference the structure type defined by the view fields of the CDS view in ABAP programs and it can be used in Open SQL statement reads (but not in Native SQL). The components of the structured type can, as usual, be specified using the structure component selector cds_entity-comp.
  • The CDS entity cannot be used as a data type in ABAP Dictionary. It cannot, for example, be used as a type of a substructure, as an include structure, or as the row type of a table type.

Both the names CDS_DB_VIEW and cds_entity are in the namespace of the data types in ABAP Dictionary. The view is also known under both names within the DDL of the ABAP CDS. In general, only the CDS entity should be accessed in ABAP programs and in other CDS entities using its name cds_entity and not the CDS database view using the name CDS_DB_VIEW.

A CDS view has two types of keys:

  • For CDS entities, KEY can be used to define key elements. This key is the semantic key of the CDS view.
  • The key of the CDS database view is determined implicitly, as in a classic view. This key is the technical key of the CDS view.

In Open SQL, the key used is determined according to whether the name of the CDS entity or the name of the CDS database view is used to access a CDS view.

Other versions: 7.31 | 7.40 | 7.54


Notes

  • The programming of CDS views using the DDL of the Core Data Services is one of the tasks included in the implementation of data models in ABAP Dictionary and is not usually the responsibility of regular ABAP application programmers. Once created, CDS views are used in ABAP programs using Open SQL read statements and must be stable enough to allow this.

  • As well as the specific functions available for CDS views, such as the definition of associations, the options for the regular SQL DDL of the CDS DDL are far more comprehensive than the form-based ABAP Dictionary tool in ABAP Workbench used to define classic views.

  • CDS views can be defined as platform-independent views. An exception to this are CDS views with input parameters, which are not currently supported by all database systems.

  • If a CDS entity is defined for a CDS view using the DCL statement DEFINE ROLE, an implicit authorization check is made in Open SQL accesses and only that data can be accessed for which a CDS authorization exists.

  • The CDS source code of a CDS view does not need to have the same name as the CDS entity or the CDS database view, however it is recommended to use the name of the CDS entity.

  • The CDS source code in a CDS view is edited in a different editor from the CDS source code of CDS role or a CDS access policy. The ADT documentation describes how the different types of source code are created.

  • A structure type defined using a CDS entity of a CDS view exists alongside the classic structures in ABAP Dictionary.

  • For CDS views, CDS view enhancements are a separate way of making enhancements without making modifications.

  • Client handling

    In a client-specific CDS view, the CDS entity does not have a client column; the CDS database view, on the other hand, does have a client column.

  • CDS authorizations

    In the case of CDS entities, a CDS role can be defined that checks the authorization of the current user when Open SQL is used to access the CDS entity. This is not possible for CDS database views.

Continue

ABAP CDS - DDL Statements

ABAP CDS - Client Handling

ABAP CDS - SAP Buffering

ABAP CDS - Data Aging