Two repository objects are created for a CDS view (of the
ABAP CDS) that is defined using DEFINE VIEW. A name must be specified for each of the two objects:
The name CDS_DB_VIEW of an
CDS-managed DDIC view must be specified in quotation marks after the
annotation@AbapCatalog.sqlViewName.
This view is the technical foundation of the CDS view in ABAP Dictionary. The usual rules for ABAP Dictionary
views apply to this name and it is not case-sensitive (it is transformed
internally into uppercase letters). The associated SQL view is created under this name on the database.
The name given to the DDIC database view can no longer be changed after the CDS view is transported into a follow-on system.
The name ddic_based_view of the
CDS entity is defined after the keywords DEFINE VIEW
(DEFINE is optional). No quotation marks need to be specified. This name
follows the rules of the CDS-managed DDIC view (obsolete), but can have 30 characters. The CDS entity represents all properties of the CDS view.
Both names are in the namespace of all
global types of an AS ABAP. and must each be unique. The name ddic_based_view of the CDS entity can be used in other CDS DDL statements or in ABAP programs to access the CDS view.
The information specified in name_list
can be used to define the names of the elements of the view in a name list. parameter_list
can be used to assign input parameters to the view. These input parameters can be specified in operand positions of the view and can be assigned actual parameters when the view is used.
Hints
The CDS-managed DDIC view (obsolete)CDS_DB_VIEW must not be used directly in CDS DDL and ABAP. Usage has been declared
obsolete. Instead, it is strongly recommended that only the
CDS entity is used, since only this entity covers all properties of the CDS view.
ABAP annotations can be used to assign further technical and semantic properties to a view for evaluation by the ABAP runtime framework.
Framework-specific annotations can be used to give the element specific semantic properties for other SAP frameworks.
If a CDS role is defined
for a CDS entity using the CDS-DCL statement DEFINE ROLE, implicit
access control applies by default when the CDS entity is accessed
using ABAP SQL. CDS access control can be switched off using the value #NOT_ALLOWED for the annotation @AccessControl.authorizationCheck
and using the addition WITH PRIVILEGED
ACCESS in the FROM clause of an ABAP SQL query.
The DDL source code of a CDS view does not need to have the same name as the CDS entity, but it is advisable to use this name.
After a piece of DDL source code is transported, the combination of its name and the name of the CDS view defined in it and its CDS-managed DDIC view is defined and can no longer be modified by being renamed.
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 and is not usually the responsibility of regular ABAP application
programmers. Once created, CDS views are used in ABAP programs using ABAP SQL read statements and must be stable enough to allow this.
The following CDS view works in exactly the same way as the DDIC projection viewDEMO_SPFLI
in ABAP Dictionary. The class CL_DEMO_CDS_PROJECTION
uses SELECT to access the view. Unlike when the DDIC view DEMO_SPFLI
is accessed, no client column is returned when the CDS entity DEMO_CDS_SPFLI
is accessed. The CDS-managed DDIC view (obsolete) DEMO_CDS_PRJCTN returns the client column too.
@AbapCatalog.sqlViewName: 'DEMO_CDS_PRJCTN' @AccessControl.authorizationCheck: #NOT_REQUIRED
define view demo_cds_spfli as select from spfli {
key spfli.carrid, key spfli.connid,
spfli.cityfrom, spfli.cityto }