SAP CDS DEFINE VIEW V1
Get Example source ABAP code based on a different SAP table
• DEFINE VIEW ddic_based ABAP_CDS_DDL_STATEMENT
• AS ABAP_CDS_DEFINE_VIEW
ABAP_CDS_DDL - DEFINE VIEW ddic_based> ABAP_SYNTAX $[@entity_annot1>$]
$[@entity_annot2>$]
...
@AbapCatalog.sqlViewName: 'CDS_DB_VIEW'>
$[@view_annot1>$]
$[@view_annot2>$]
...
$[DEFINE$] $[ROOT>$] VIEW ddic_based_view
$[name_list>$]
$[parameter_list>$]
AS select_statement> $[;$] >
What does it do?
Defines a ABAP_CDS_V1_VIEW > in the CDS DDL>. A CDS view is implemented using a query select_statement>>. The annotation> AbapCatalog.sqlViewName> > must be specified before the view itself is defined using DEFINE VIEW>. Further optional annotations entity_annot1>>, ..., view_annot1>>, ... can also be specified.
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 ABAP_CDS_MNG_VIEW , 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.
Latest notes:
The ABAP_CDS_MNG_VIEW > 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 AB-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 AB-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.