SAP - ABAP CDS Development User Guide: Warning
SAP - ABAP CDS Development User Guide: Warning
SAP - ABAP CDS Development User Guide: Warning
PUBLIC
Warning
This document has been generated from the SAP Help Portal and is an incomplete version of the official SAP product
documentation. The information included in custom documentation may not re ect the arrangement of topics in the SAP Help
Portal, and may be missing important aspects and/or correlations to other topics. For this reason, it is not for productive use.
https://help.sap.com/http.svc/dynamicpdfcontentpreview?deliverable_id=22068427&topics=4ed1f2e06e391014adc9fffe4e20… 1/91
12/30/2019
Target Audience
ABAP developers who are involved in the code push-down development activities.
Validity of Documentation
This documentation belongs to ABAP Development Tools for SAP NetWeaver client version 2.80 and refers to the range of
functions that have been shipped as part of the standard delivery for SAP NetWeaver AS for ABAP 7.51 innovation package SP03.
Tip
You can also visit our ABAP for SAP HANA space on SCN to view discussions and nd further resources on how ABAP-
based applications can leverage SAP HANA.
Overview
ABAP CDS provides a framework for de ning and consuming semantic data models on the central database of the application
server AS ABAP. The speci ed data models are based on the data de nition language (DDL) and the data control language (DCL).
So, a CDS entity or the extension of a CDS view is de ned as source code in the data de nition.
Remember
https://help.sap.com/http.svc/dynamicpdfcontentpreview?deliverable_id=22068427&topics=4ed1f2e06e391014adc9fffe4e20… 2/91
12/30/2019
In the DDL editor, you can only de ne one ABAP CDS entity in one data de nition or metadata extension.
Related Information
ABAP CDS in ABAP Dictionary (ABAP Keyword Documentation)
A CDS view is de ned for existing database tables and views, or for other CDS views in the ABAP Dictionary, using the DEFINE
VIEW DDL statement. A CDS view serves to de ne the structure of a CDS database view and represents a projection onto one or
several database tables or database views in the ABAP Dictionary.
Note
CDS database views and CDS entities are part of one and the same namespace. Therefore, you must assign different names for
a CDS database view and the entity.
Example
@AbapCatalog.sqlViewName: 'CUSTOMER'
DEFINE VIEW cust_book_view_entity AS SELECT FROM scustom
JOIN sbook
ON scustom.id = sbook.customid
{
scustom.id,
scustom.name,
https://help.sap.com/http.svc/dynamicpdfcontentpreview?deliverable_id=22068427&topics=4ed1f2e06e391014adc9fffe4e20… 3/91
12/30/2019
sbook.bookid
}
The cust_book_view_entity CDS entity de nes a projection onto the database tables scustom and sbook by joining
both tables. The generated CDS database view (CUSTOMER) comprises the ID, the name, and the booking ID of all customers
for which the bookings exist.
Example
ENDMETHOD.
...
ENDCLASS.
https://help.sap.com/http.svc/dynamicpdfcontentpreview?deliverable_id=22068427&topics=4ed1f2e06e391014adc9fffe4e20… 4/91
12/30/2019
Note
When activating a data de nition, a CDS entity and CDS database view form a unity with the data de nition as development
object. So, after transporting the data de nition, the name of the CDS entity and CDS database view can no more be changed.
To rename any part of this unity, you need to delete the corresponding data de nition. Consequently, you recreate it and use
the new name for the relevant part.
Developer-Relevant Activities
1. Creating Data De nitions
7. [Optional:] Analyzing the SQL dependency tree of the view in case of more complex CDS views
Caution
Before deleting DDL, check whether it is still being used by other development objects. To nd out if an object is still in
use, call the where-used function( Searching Usages (Where-Used)). See also: Deleting Development Objects
Related Information
ABAP CDS - View (ABAP Keyword Documentation)
The actual CDS entity of the table function that is generated in the ABAP Dictionary
Note
In contrast to the CDS views, the CDS table functions can be implemented using Native SQL. This implementation is done
within an AMDP method of an AMDP class and is managed as an AMDP function by the AMDP framework in the database
system.
https://help.sap.com/http.svc/dynamicpdfcontentpreview?deliverable_id=22068427&topics=4ed1f2e06e391014adc9fffe4e20… 6/91
12/30/2019
Note
The name of the implementing AMDP method can only be speci ed in a single CDS table function (1: 1 relation).
Example
Table Function De nition
In the following listing, a client-speci c ABAP CDS table function TAB_FUNCTION_EXAMPLE is de ned using the DDL syntax.
This table function declares two input parameters clnt (with the prede ned value: #CLIENT) and carrid, and a list of
elements that provide the return values of the AMDP method that implements the table function. The table function is
associated with the AMDP class CL_EXAMPLE_AMDP, where the method GET_FLIGHTS is used to implement the table
function.
Sample Code
@ClientDependent: true
@AccessControl.authorizationCheck: #NOT_REQUIRED
define table function TAB_FUNCTION_EXAMPLE
Example
https://help.sap.com/http.svc/dynamicpdfcontentpreview?deliverable_id=22068427&topics=4ed1f2e06e391014adc9fffe4e20… 7/91
12/30/2019
Table Function Implementation
The public ABAP class (AMDP class) in this example provides the AMDP method get_flights, which serves as the
implementation of the table function tab_function_example. As with any other AMDP class,
cl_example_amdp must implement the marker interface IF_AMDP_MARKER_HDB. The AMDP method get_flights
implements the data selection using Native SQL code.
Sample Code
public section.
interfaces IF_AMDP_MARKER_HDB.
class-methods get_flights for table function tab_function_example.
protected section.
private section.
endclass.
endclass.
Developer-Relevant Activities
1. Creating Data De nitions
Related Information
ABAP CDS Synatx – Table Functions (ABAP Keyword Documentation)
The development object for CDS unit testing is a CDS view for which the runtime entity is in database layer (SQL View). Using CDS
Test Double Framework APIs available in ABAP unit class, you can write an ABAP unit test for a CDS View for runtime artifacts that
are in two different layers. You can also create test doubles for database entities.
Note
The double has the same structure as the original dependent component.
Copies depended-on database tables, but do not copy its data and primary key constraints
Creates database tables for depended-on database views. These tables have the same structure as the depended
on database views
Copies depended-on database functions (resulting from depended-on CDS views with parameters) and modi es
the implementation of function double to "insert" desired test-data into the double
DDIC tables
DDIC views
CDS views
External Views
Table Functions
Note
You can also turn on/off DCL for a given CDS. We recommend you to turned off DCL to truly isolate the CDS during unit testing.
Related Information
Unit Testing in ABAP
Writing Unit Tests Using CDS Test Double Framework
Access Controls
ABAP Core Data Services (CDS) has its own authorization concept based on a data control language (DCL). The authorization
concept of ABAP CDS uses conditions de ned in CDS and can draw upon classical (PFCG) authorizations to check the
authorizations of users.
https://help.sap.com/http.svc/dynamicpdfcontentpreview?deliverable_id=22068427&topics=4ed1f2e06e391014adc9fffe4e20… 9/91
12/30/2019
The CDS authorization concept coexists with the classical authorization concept of SAP NetWeaver Application Server for ABAP
(SAP NetWeaver AS for ABAP). You can use the concepts together or independently from another. The classical authorization
concept is based on authorization objects. The authorization of a user occurs either implicitly, for example while calling a
transaction, or explicitly with the statement AUTHORITY-CHECK. The CDS authorization concept is based on implicit
authorization checks that occur during access attempts to CDS entities over service adaptation de nition language (SADL) or
Open SQL.
A developer de nes a CDS role in a separate CDS source code for a CDS entity using the DCL statement DEFINE ROLE. When a
CDS entity is accessed using SADL or Open SQL, the following is checked:
If no role is de ned for a CDS entity, there are no restrictions on the data returned by the query.
If a role is de ned for the CDS entity, access control management checks the current user for authorizations. The system
only reads data for which an authorization exists. CDS roles are assigned to all users implicitly.
When you activate an access control, SAP NetWeaver AS for ABAP generates the authorization views and lls the access control
management tables with the required metadata. The roles are characterized as global internal objects in the ABAP Dictionary.
Notes
We recommend that you continue to use the classical authorization concept for start authorizations. Start authorizations check
whether a user can start an application in the rst place. The CDS authorization concept can be used within an application to
perform instance-based authorization checks. Instance-based authorization checks the authorization of a user as de ned by the
data model and the data in question.
Related Information
https://help.sap.com/http.svc/dynamicpdfcontentpreview?deliverable_id=22068427&topics=4ed1f2e06e391014adc9fffe4e2… 10/91
12/30/2019
Adding Access Controls to CDS Entities
ABAP CDS - Access Control (ABAP Keyword Documentation)
CDS Annotations
A CDS annotation (or annotation for short) enables you to add ABAP and component-speci c metadata to the source code of any
CDS entity.
Use
You can use code completion ( Ctrl + Space ) to add annotations directly in a data de nition, for example, before the define
statement or within a select list in a CDS view. The validity of the annotation then depends on the corresponding position where
you use it. If they are added at the wrong position, the source editor will mark and underline them in red.
In addition, you can use annotations in metadata extensions to de ne customer-speci c metadata for a CDS view without
modifying SAP's CDS entities itself. When using metadata extensions, you can overwrite speci c annotation values de ned in a
data de nition or add additional annotation values to an entity. Note that you can only use those annotations in metadata
extensions that are not relevant when activating CDS entities.
Example
@AbapCatalog.sqlViewName: 'CUSTOMER'
@AccessControl.authorizationCheck: #NOT_REQUIRED
@Metadata.allowExtensions: true
DEFINE VIEW cust_book_view_entity
AS SELECT FROM scustom
JOIN sbook
ON scustom.id = sbook.customid
{
@EndUserText.label: 'Customer ID'
scustom.id,
@EndUserText.label: 'Customer Name'
scustom.name,
@EndUserText.label: 'Customer Booking ID'
sbook.bookid
}
The example from above demonstrates how you can use annotations and at which positions you can add annotations:
Annotations that are used before the define view statement are valid for the whole cust_book_view_entity
CDS view:
https://help.sap.com/http.svc/dynamicpdfcontentpreview?deliverable_id=22068427&topics=4ed1f2e06e391014adc9fffe4e2… 11/91
12/30/2019
The @EndUserText.label annotation used before an element in the select list provides a text for the
corresponding eld.
Activation
Errors resulting from the use of component annotations do not prevent activation or creation of a CDS entity at the rst time. They
are only evaluated if the activation of the entity was successful.
Component annotations can result in the generation of other ABAP repository objects.
Example
An OData service is generated when using the @OData.publish: true annotation. In this case, the annotation is
highlighted with a marker that provides additional information about the generated object.
Note
When the CDS entity is activated, the OData service is generated automatically. After activation, it can be opened from the
ABAP Element Information popup of the corresponding database table. To do this, select the underlined "OData-Service"
link in the Generated Object section.
Subsequently, the OData service also needs to be activated in the transaction /IWFND/MAINT_SERVICE manually.
Related Information
ABAP CDS - Annotations (ABAP Keyword Documentation)
CDS Annotations (Framework-Speci c Reference Documentation)
Annotation Propagation
Active Annotations View
Displaying Annotation Values of an Active CDS View
Extracting CDS Annotations to a Metadata Extension
Activate OData Service in the SAP Gateway Hub
Annotation Propagation
The values of CDS annotations can be inherited and merged between CDS entities.
Use
https://help.sap.com/http.svc/dynamicpdfcontentpreview?deliverable_id=22068427&topics=4ed1f2e06e391014adc9fffe4e2… 12/91
12/30/2019
You as a developer have the following possibilities to use annotations in order to provide metadata in your data model:
Use metadata extensions to enrich a CDS entity with customer-speci c annotation values
You can build hierarchies when selecting data from other CDS views. In accordance to this hierarchy and the corresponding
elements in the select list, the annotation values are propagated from bottom to top. In addition, you can also use metadata
extensions. Note that metadata extensions can also re ect a hierarchy when assigning several metadata extensions to a CDS view.
You can assign customer-speci c metadata through annotations in one or more metadata extensions to one data de nition.
The precedence of the annotations contained in the metadata extensions is determined by the layer of the extension. For this the
following values are provided:
Value Description
Example
@Metadata.layer: #CUSTOMER
Note
All annotations provided in metadata extensions are compounded with the
annotations in the corresponding data de nition. Element annotations
(scope ELEMENT) are propagated in the view hierarchy.
You use the Annotation Propagation view to display the currently active and inactive values of CDS annotations and the CDS
entities from which these values have been propagated in accordance to the current position of the cursor in the DDL editor.
Source CDS entity or metadata extension from which the value of a CDS annotation originates.
If you provide several metadata extensions for a data de nition, you can reproduce how metadata extensions provide
metadata on different layers.
https://help.sap.com/http.svc/dynamicpdfcontentpreview?deliverable_id=22068427&topics=4ed1f2e06e391014adc9fffe4e2… 13/91
12/30/2019
After generating, all involved annotation values and their corresponding data sources are listed. The effective entries are
highlighted in black. The metadata that is ignored is highlighted grey. Based on this list, you can now check which values are
considered from your data de nition.
You can also adapt the selection of the data source at any time. To do this, choose the corresponding Browse... button in the
Selection area. Select then the relevant data source or key.
Example
The following example visualizes merging annotations through the ABAP API:
Precedence of the metadata contained in the data definitions and metadata extensions is as follows: <CUSTOMER Extension 2> > <PARTNER
Extension 2> > <CDS View 2> > <CUSTOMER Extension 1> > <CORE Extension 1> > <CDS View 1>
The active annotations returned by the API for the elds of the CDS View <CDS View 2> are as follows:
https://help.sap.com/http.svc/dynamicpdfcontentpreview?deliverable_id=22068427&topics=4ed1f2e06e391014adc9fffe4e2… 14/91
12/30/2019
Related Information
ABAP CDS - Evaluation of Annotations (ABAP Keyword Documentation)
ABAP CDS - Evaluation of Metadata Extensions (ABAP Keyword Documentation)
Annotation Propagation View
Analyzing Annotation Propagations
You can use the following CDS view extensions to extend CDS entities:
Extend Views to add new elements to a CDS view from its underlying data source or de ne new associations for the CDS
view.
Metadata Extensions to overwrite existing or add new CDS annotations to a one or more elements or parameters of a CDS
entity.
Overview
The following example shows you how to extend a CDS view:
Example
In the select list of the cust_book_view_entity CDS view:
The metadata of the scustom.id, scustom.name, and scustom.bookid elds is overwritten by the metadata
extension. When the corresponding data de nition is consumed, the metadata of the metadata extension is taken into
account.
The scustom.street and scustom.city database elds are added through the extend view. When you select
data from the corresponding data de nition, the data of these database elds will also be retrieved.
https://help.sap.com/http.svc/dynamicpdfcontentpreview?deliverable_id=22068427&topics=4ed1f2e06e391014adc9fffe4e2… 15/91
12/30/2019
Possibilities to overwrite existing CDS annotations as well as to add elements to a CDS view
After creating a CDS view extension, the indicator is added at the define view statement to indicate that the select list of
the view has been extended.
Marker that indicates that the select list of the CDS view has been extended
Metadata Extensions
As of SAP NetWeaver AS for ABAP 7.51 innovation package, you can use metadata extenstions to add customer-speci c
requirements to SAP's CDS entities. Note that these changes do not result in modi cations.
De nition
A metadata extension is a transportable ABAP development object that provides CDS annotations in order to extend the CDS
annotations used in a CDS view.
Use
https://help.sap.com/http.svc/dynamicpdfcontentpreview?deliverable_id=22068427&topics=4ed1f2e06e391014adc9fffe4e2… 16/91
12/30/2019
Metadata extensions enable you to write the annotations for a CDS view in a different document to separate them from the CDS
view.
Overview
CDS views are not extensible by default.
To use a metadata extension for a CDS view, you have to consider the following conditions:
1. In the de nition of the CDS view, the @Metadata.allowExtensions annotation with the value true is added. This
annotation allows explicitly the use of metadata extensions.
2. In the metadata extension, you have to de ne the name of the CDS view to be annotated in the annotate view
statement.
3. In the Switch Framework, a switch is assigned to metadata extensions in order to control provisioning of metadata through
metadata extensions at runtime.
The switch state enables system administrators to control the visibility of repository objects or their components by means
of switches.
Advantages
You can bene t from the following advantages using metadata extensions:
1. Separation of Concerns: Separating the metadata speci ed in the annotations from the implementation of the view:
In addition, the metadata can be developed and updated independently of the data de nition.
2. ABAP Dictionary-independent activation: When activating a CDS view, the metadata extensions will be ignored. This
results in the following advantages:
It reduces the number of ABPA Dictionary (mass-)activations required to develop and maintain the CDS view.
It facilitates changing the metadata of a CDS view in a running system, thereby reducing downtime.
3. Modi cation-free enhancements: Customers, partners, and industries can customize the metadata without modifying the
CDS view.
In addition, metadata extensions are switchable. This means the metadata can be speci cally enabled or disabled
depending on the use case.
Activation
In general, in a metadata extension only those annotations are permitted that do not affect the ABAP Dictionary
activation/generation or the activation/generation of secondary objects (for example, OData services). Currently only the ABAP
annotation @EndUserText and the component-speci c annotations @UI can be speci ed in metadata extensions. A syntax
error occurs if annotations that are not permitted are speci ed.
https://help.sap.com/http.svc/dynamicpdfcontentpreview?deliverable_id=22068427&topics=4ed1f2e06e391014adc9fffe4e2… 17/91
12/30/2019
the metadata in the CDS view and also with the metadata that is inherited from underlying views (and metadata extensions) in the
view hierarchy.
Related Information
ABAP CDS Metadata Enhancements (ABAP Keyword Documentation)
Extracting CDS Annotations to a Metadata Extension
Creating Metadata Extensions
Annotation Propagation
Extend Views
In the context of Core Data Services (CDS), you create an extend view to add more elds from the basis entities to the associated
CDS view without making any modi cations.
Entry to add the Extend View template through the creation wizard of data definitions
In this template, the following placeholders are provided and need to be adapted:
${sql_view_append_name}: Name of the append structure to be created in the ABAP Dictionary when activating the
extend view
https://help.sap.com/http.svc/dynamicpdfcontentpreview?deliverable_id=22068427&topics=4ed1f2e06e391014adc9fffe4e2… 18/91
12/30/2019
${ddl_source_name_editable}: Name of the extend view object itself
${data_source_name}: Name of the data source (for example, a database or a CDS view) from which you want to add new
database elds to the CDS view
${element_name}: Name of the database eld or element (for example, an association) to be added
Note
You can only add those database elds (or constants) that are contained in the same basis database that is used in the
select list of the CDS view.
Related Information
ABAP CDS - EXTEND VIEW (ABAP Keyword Documentation)
Creating Data De nitions
Prerequisites
You need the standard developer authorization pro le to create ABAP development objects.
Context
With a data de nition you have the appropriate ABAP development object, which you can use directly to access the standard
ABAP Workbench functionality (transport, syntax check, activation).
Procedure
1. In your ABAP project, select the relevant package node in the Project Explorer.
2. Open the context menu and choose New Other... Core Data Services Data De nition to launch the creation wizard.
3. In addition to the Project and Package, enter the Name and the Description for the data de nition to be created.
Note
The maximum length for names of data de nition is 30 characters.
4. Choose Next.
https://help.sap.com/http.svc/dynamicpdfcontentpreview?deliverable_id=22068427&topics=4ed1f2e06e391014adc9fffe4e2… 19/91
12/30/2019
6. Choose Next.
By default, ABAP Development Tools considers the template for creation that you have selected at the last time.
8. Choose Finish.
Results
In the selected package, the ABAP back-end system creates an inactive version of a data de nition and stores it in the ABAP
Repository.
In the Project Explorer, the new data de nition is added to the Core Data Services folder of the corresponding package node. As a
result of this creation procedure, the source editor will be opened. Here, you can start de ning a CDS entity.
Related Information
ABAP CDS Entities
ABAP Development Objects
Editing DDL Source Code
Context
https://help.sap.com/http.svc/dynamicpdfcontentpreview?deliverable_id=22068427&topics=4ed1f2e06e391014adc9fffe4e2… 20/91
12/30/2019
To generate a CDS view, you must activate the data de nition.
Procedure
1. To activate the data de nition from the DDL editor ...
b. Click the icon (Activate the ABAP Development Object) in the toolbar.
Tip
Alternatively, you can use the shortcut Ctrl + F3 .
a. Select the node of the relevant data de nition in the ABAP project in the Project Explorer.
Results
In the selected ABAP package, the ABAP back-end system creates an active version of the CDS view and the CDS database view
and stores them in the ABAP Dictionary. Both are added to the Dictionary folder of the selected package.
Note
You can specify the client dependency of the CDS view using the @ClientHandling CDS annotation, which is available
since SAP NetWeaver AS for ABAP 7.51 innovation package SP00. If the CDS view is client-dependent, the client eld is
automatically added to the CDS database view.
Related Information
Displaying Activation Log for Data De nitions
Status of a Development Object
Previewing Data Records
Procedure
1. To view the activation log for an error item in the Problems view, select the corresponding function in the context menu.
2. To view the activation log from the DDL editor, choose the toolbar menu Navigate Open Navigation Log .
Note
If activation errors should ever occur, it can be of advantage for you to be able to get more information on diagnosis and
troubleshooting. This information is provided with the activation log.
Related Information
https://help.sap.com/http.svc/dynamicpdfcontentpreview?deliverable_id=22068427&topics=4ed1f2e06e391014adc9fffe4e2… 21/91
12/30/2019
Troubleshooting for Dictionary Activation Errors
Prerequisites
You can use the SQL statement viewer for active, inactive, and even unsaved (“dirty”) data de nitions – if the source code
is syntactically correct. Otherwise, you receive a corresponding message: DDL Statement could not be created. Check
data de nition for syntax errors.
Context
Let's imagine you realize that some unexpected behavior took place when you were accessing CDS entities for data selection.
Then you will possibly need to check the syntax of the native SQL statements generated at database level.
The generated SQL data types, based on their de nition in the CDS table functions when running AMDP procedures
The JOIN structure at database level when using associations in CDS view de nitions.
Procedure
1. Open the relevant CDS entity (CDS view, CDS table function) in the DDL editor.
3. Open the context menu and choose Show SQL CREATE Statement .
Results
The corresponding SQL CREATE statement is displayed in the element information popup.
The SQL syntax for CREATE FUNCTION is displayed in the element info popup
Tip
https://help.sap.com/http.svc/dynamicpdfcontentpreview?deliverable_id=22068427&topics=4ed1f2e06e391014adc9fffe4e2… 22/91
12/30/2019
From within the element info popup, you have the option to open the ABAP Element Info view by clicking the Show in ABAP
Element Info View icon ( @ ).
Prerequisites
You need the standard developer authorization pro le to create ABAP development objects.
Context
You want to provide additional metadata using CDS annotations to a CDS entity.
Procedure
1. In your ABAP project, select the relevant package node in the Project Explorer.
2. Open the context menu and choose New Other ABAP Repository Object Core Data Services Metadata Extension to
launch the creation wizard.
3. In addition to the Project and Package, enter the Name and the Description for the metadata extension to be created.
Note
The maximum length for names of metadata extensions is 30 characters.
4. Choose Next.
6. Choose Next.
https://help.sap.com/http.svc/dynamicpdfcontentpreview?deliverable_id=22068427&topics=4ed1f2e06e391014adc9fffe4e2… 23/91
12/30/2019
7. [Optional:] If requested, select a template.
By default, ABAP Development Tools considers the template for creation that you have selected at the last time.
8. Choose Finish.
Results
In the selected package, the ABAP back-end system creates an inactive version of a metadata extension and stores it in the ABAP
Repository.
In the Project Explorer, the new metadata extension is added to the Core Data Services folder of the corresponding package
node. As a result of this creation procedure, the source editor will be opened. Here, you can start de ning a metadata extension.
After developing and checking your new object, you can activate it.
Related Information
Activating Development Objects
Prerequisites
You need the standard developer authorization pro le to create ABAP development objects.
Context
You want to relocate the annotations of a data de nition to a new metadata extension to be created.
Note
The annotations are removed from the data de nition after extraction.
You can only extract those annotations that are allowed for usage in metadata extensions.
Procedure
1. Open the source editor for the relevant data de nition.
2. Open the context menu in the source editor and choose Source Code Extract Metadata Extension to launch the Extract
Metadata Extension wizard.
https://help.sap.com/http.svc/dynamicpdfcontentpreview?deliverable_id=22068427&topics=4ed1f2e06e391014adc9fffe4e2… 24/91
12/30/2019
3. In addition to the Project and Package, enter the Name and the Description for the metadata extension to be created.
Note
The maximum length for names of metadata extensions is 30 characters.
4. Choose Next.
Wizard page for defining the annotations to be extracted to the new metadata extension
https://help.sap.com/http.svc/dynamicpdfcontentpreview?deliverable_id=22068427&topics=4ed1f2e06e391014adc9fffe4e2… 25/91
12/30/2019
The annotations of the data de nition that can be extracted to the new metdata extension are listed here.
Note
Annotation values of type array must be set in square brackets in metadata de nitions. If the array values in your
data de ntion are not set in square brackets, then you can use the Insert missing square brackets for annotation
values of type array checkbox to automatically insert the brackets when the annotation is extracted.
For more information, look here ABAP CDS - Annotation Arrays (ABAP Keyword Documentation)
6. Choose Next.
8. Choose Finish.
Results
The ABAP back-end system creates an inactive version of a metadata extension and stores it in the ABAP Repository.
In the Project Explorer, the new metadata extension is added to the Core Data Services folder of the corresponding package
node. The source editor of the metadata extension is opened and the extracted annotations are added. Therefore, the source code
of the metadata extension becomes dirty.
The editor of the data de nition also becomes dirty. Here, the annotations are deleted from its source code.
Consequently, you must save and activate both development objects to apply the changes.
Related Information
Annotation Propagation View
Creating Development Objects
Related Information
Getting Help for DDL Source Code
Getting Support from the Content Assist
Using Data De nition Templates
Navigating Associations
Applying Quick Fixes
De ning ON Conditions by Use of a Wizard
Adding and Removing Comments
Changing Colors of DDL and DCL Source Code
Comparing DDL Source Code Versions
https://help.sap.com/http.svc/dynamicpdfcontentpreview?deliverable_id=22068427&topics=4ed1f2e06e391014adc9fffe4e2… 26/91
12/30/2019
Displaying and Navigating to CDS View Extensions
Displaying Annotation Values of an Active CDS View
In addition, you may need to display the de nition and documentation of elements used, like tables, views, or individual table
elds that you used when de ning CDS views in the DDL editor. For this purpose, press F2 to access the code element info
popup.
Tip
In addition, you will nd the complete ABAP CDS - Language Elements (ABAP Keyword Documentation) on the SAP Help
Portal.
https://help.sap.com/http.svc/dynamicpdfcontentpreview?deliverable_id=22068427&topics=4ed1f2e06e391014adc9fffe4e2… 27/91
12/30/2019
Tip
From within the element info popup, you have the option to open the ABAP Element Info view by pressing the Show in ABAP
Element Info View icon.
Tip
When opening the element info popup for a table, you have the option to show a tree-based display that indicates the includes
or append structures – if they are de ned for the table elds.
https://help.sap.com/http.svc/dynamicpdfcontentpreview?deliverable_id=22068427&topics=4ed1f2e06e391014adc9fffe4e2… 28/91
12/30/2019
Keyword completion: The best matching DDL keyword is automatically proposed as soon as you start typing
Semantic keyword completion: A list of all matching DDL keywords is displayed for the position where you have chosen
the Ctrl + Space shortcut
Semantic completion (data source and signature parameter completion): This enables you to insert the best matching
data sources (tables) or add the parameters of a table to the DDL source code.
Keyword Completion
In the DDL source code editor, the best matching DDL keyword is displayed when start typing the keyword. If you choose the
tabulator key, the keyword is inserted.
https://help.sap.com/http.svc/dynamicpdfcontentpreview?deliverable_id=22068427&topics=4ed1f2e06e391014adc9fffe4e2… 29/91
12/30/2019
In the DDL source editor, you can open the code completion list manually at any position by choosing Ctrl + Space . This
enables you to add the possible keywords to your source code using the Shift + Enter shortcut.
Choose Ctrl + Space to display the list of suggested entries at this position
Semantic Completion
To get a list of best matching data sources (database tables, database views, CDS views, or CDS table functions), type the rst
letter(s) of the data source and then press Ctrl + Space .
The list with the elements of the signature is automatically displayed after you have typed a dot as the component selector. This
enables you to add a component of a table to the DDL source code.
https://help.sap.com/http.svc/dynamicpdfcontentpreview?deliverable_id=22068427&topics=4ed1f2e06e391014adc9fffe4e2… 30/91
12/30/2019
If you add the name of an element that is also used for another data source, ADT will automatically add the name of the relevant
data source as pre x. This makes clear which element needs to be considered. Both names are separated with a dot.
To always add the name of the relevant data source to the element as pre x, choose the Always pre x elements with data source
name checkbox in the preferences.
Related Information
Getting Support from the Content Assist
To use a template...
1. In the DDL source editor, write the beginning characters of the template.
Tip
Alternatively, you can use the Templates view to insert the code template in the DDL editor using drag & drop.
https://help.sap.com/http.svc/dynamicpdfcontentpreview?deliverable_id=22068427&topics=4ed1f2e06e391014adc9fffe4e2… 31/91
12/30/2019
2. Open the New Template dialog. Specify the Name and the Description, and edit the Pattern of the template.
Tip
If you want to add the new template to the data de nition creation wizard, select Data De nition (creation) as the
Context.
To add variables to the template in the Pattern eld, choose the Insert Variable... button.
Related Information
Creating and editing templates
Java Editor Template Variables
Navigating Associations
In addition to the F3 Eclipse navigation functionality, you can also navigate between the origin, the de nition, and the target of
the associations you are using in your data de nition.
2. Open the context menu on the name and chose Navigate To.
Note
Alternatively, you can press F3 or Ctrl + click . A small dialog is then opened below the association name. Here you
choose Navigate To.
The corresponding data de nition id opened and highlights the relevant origin or navigates to the relevant de nition within the
same data de nition. In both cases, the selected occurrences and names are highlighted.
2. Open the context menu on the name and chose Navigate To Target.
Note
https://help.sap.com/http.svc/dynamicpdfcontentpreview?deliverable_id=22068427&topics=4ed1f2e06e391014adc9fffe4e2… 32/91
12/30/2019
Alternatively, you can press Ctrl + click . A small dialog is then opened below the association name. Here you choose
Navigate To Target.
Related Information
Opening Development Objects
Effect: Adds the annotation @AbapCatalog.sqlViewName: 'SQL_VIEW_NAME' , which speci es the name of the
CDS database view to be generated in the ABAP Dictionary.
Effect: Adds the GROUP BY clause that is required if aggregate functions (MAX, SUM, ...) are contained in the SELECT list.
In addition, all elements not de ned using aggregate functions are speci ed after GROUP BY.
Effect: If the GROUP BY clause is already added, you can extend this group to include all elements not de ned using
aggregate functions and not yet part of the GROUP BY clause. The latter elements, when included, are also added to the
existing GROUP BY clause.
Alias is missing
Effect: Adds an alternative name (alias) for each aggregate function that is used as an element in the SELECT list.
b. Choose Quick x.
c. In the list of possible quick xes, double-click the relevant quick x function.
b. In the list of possible quick xes, double-click the relevant quick x function.
https://help.sap.com/http.svc/dynamicpdfcontentpreview?deliverable_id=22068427&topics=4ed1f2e06e391014adc9fffe4e2… 33/91
12/30/2019
a. In the DDL editor, position the cursor where the error occurs and is highlighted.
Prerequisites
This function affects the CDS view in the currently opened editor.
Context
You can use the ON conditions wizard when de ning:
The wizard considers the used data sources and their elements and provides proposals (strategies) for joining the data sources.
As developer you can also specify the elements for a JOIN manually using drag and drop (User De ned strategy).
Procedure
1. Open the relevant CDS view in the DDL editor.
2. In the CDS source code, position the cursor on the ON keyword where you want to de ne an ON condition for a join or
association.
https://help.sap.com/http.svc/dynamicpdfcontentpreview?deliverable_id=22068427&topics=4ed1f2e06e391014adc9fffe4e2… 34/91
12/30/2019
4. On the quick x view, double-click the De ne ON conditions entry to start the wizard.
Note
If the ON condition already exists, the mapping between elements of data sources will be displayed on the wizard page,
where you can then modify them.
5. To specify the condition expression, de ne the mapping between the source and the target data source.
The wizard offers you automatic proposals for mapping elements of the data sources:
Strategy > By Name: Elements with identical names are mapped to each other.
Strategy > By Foreign Key: Based on the foreign key relationship, that has been de ned for a table in the ABAP
Dictionary, mappings are suggested for each key de nition.
When using the User De ned option, you can map the elements in a straightforward manner using drag & drop.
In addition, the wizard provides you with additional functionality, so that you can:
Name
Dictionary type
Built-in type
$parameter
$projection
data source
Tip
To open the context menu on the wizard page, select the relevant element from the Source or Target area.
https://help.sap.com/http.svc/dynamicpdfcontentpreview?deliverable_id=22068427&topics=4ed1f2e06e391014adc9fffe4e2… 35/91
12/30/2019
For defining mapping drag and drop relevant elements from source to target
6. Choose Finish.
Results
The wizard inserts the corresponding condition expression after the ON keyword into the DDL source code.
Note
The wizard does not check the syntax or semantic correctness of a CDS view. So, the modi ed coding might contain syntax or
semantic errors.
Related Information
ABAP CDS – SELECT, Association (ABAP Keyword Documentation)
ABAP CDS – SELECT, JOIN (ABAP Keyword Documentation)
You can also use the following shortcuts for comments in the DDL editor:
https://help.sap.com/http.svc/dynamicpdfcontentpreview?deliverable_id=22068427&topics=4ed1f2e06e391014adc9fffe4e2… 36/91
12/30/2019
Ctrl + < Add Comment The editor inserts a double slash (//) at the
beginning of each selected line.
Ctrl + > Remove Comment The editor removes an existing double slash
(//) at the beginning of each selected line.
Note
Alternatively, you can access the comments functions using the context menu entries of the DDL source editor ( Source Add
Comment... )
Context
You can de ne the color for displaying the keywords, identi ers, annotation, or further code elements in DDL and DCL source
code.
Procedure
1. Open the General Appearance Colors and Fonts preference page.
3. Select the text type you want to change and click the Edit... button.
Remember
To restore the default color settings, click the Restore Defaults button.
Results
The new color settings become immediately effective in the corresponding editor.
Context
You want to get an overview of the CDS view extension(s) of a CDS view.
Procedure
1. In the vertical ruler of the DDL source editor, hover over the marker.
Note
This marker indicates for each CDS view that a CDS view extension is assigned to the data de nition.
As of SAP NetWeaver AS for ABAP 7.51 innovation package SP00, the marker also enables you to navigate to the extend
view or metadata extension directly.
One or more object links that refer to the relevant CDS view extensions
2. To navigate to the CDS view extension that exists in the system, choose the underlined object name from the extension
popup.
Results
The CDS view extension is opened.
Formatting DDL
https://help.sap.com/http.svc/dynamicpdfcontentpreview?deliverable_id=22068427&topics=4ed1f2e06e391014adc9fffe4e2… 38/91
12/30/2019
You format DDL source code (such as a CDS statement, including the element list, Boolean expressions, JOINs, association
de nitions, and so on) to structure the code and to improve its readability.
In the context of editing DDL source code, the following use cases are supported:
1. Using the SAP standard pro le: You want to use the standard pro le prede ned by SAP. This pro le is provided by default
and can be used immediately.
Note
The SAP standard pro le is persisted in the back end. This ensures that the formatting result is always consistent –
independently of the installed ADT client version.
The SAP standard pro le might differ slightly between SAP NetWeaver releases. Therefore, formatting results might
also differ between ABAP projects.
2. Creating your own pro le: If the SAP standard pro le does not meet your needs, you can create and use your own pro le.
In addition, you can import or export a pro le to reuse/share it from/with other ADT developers.
Note
The local con guration is persisted in the Eclipse-based IDE workspace.
3. Overruling the SAP standard pro le for your team or company: If a team decides to use its own pro le, they can export a
pro le and make it available for all data de nitions of an ABAP package.
Note
A team pro le is persisted in the back end. It does not need to be enabled. On the basis of the ABAP package, the DDL
formatter detects whether the SAP standard pro le or the team pro le is to be used.
The DDL formatting settings are con gured in the ABAP Development preferences.
Example of the first Preferences page for configuring the DDL formatter
Starting from the ABAP Development Editors Source Code Editors DDL Formatter Preferences page, you have the following
general options:
DDL formatting is not automatically executed by default. To perform this, select the Format DDL on save checkbox in
advance.
https://help.sap.com/http.svc/dynamicpdfcontentpreview?deliverable_id=22068427&topics=4ed1f2e06e391014adc9fffe4e2… 39/91
12/30/2019
DDL formatting is con gured through pro les. Thus, you can:
Select the pro le you want to work with on your local IDE.
Create your own pro le(s), Edit it (them) at a later point in time, and Remove it (them).
Work with SAP 's standard pro le where the settings of the DDL formatter are already pre-con gured.
You can Restore Defaults to cancel your changes and revert to the default provided by SAP.
To execute the DDL formatter, use the context menu Source Code Format or the Shift + F1 shortcut at every position. If you
have selected the Format DDL on save checkbox on the DDL Formatter preferences page, formatting is automatically performed
when you save your changes.
Related Information
Creating a Pro le
De ning a Package-Speci c Pro le
Editing Pro les
Importing Local Pro les
Exporting Local Pro les
Creating a Pro le
You can create a pro le to con gure your own client-speci c formatting of data de nitions or to provide your pro le to a team of
ABAP developers using ADT.
Procedure
1. Open the ABAP Development Editors Source Code Editors DDL Formatter preference page.
4. [Optional:] To reuse the con guration of another pro le, select the relevant one from the Initialize settings with the
following pro le: dropdown listbox.
5. [Optional:] To con gure your pro le at a later point of time, deselect the Open the edit dialog now checkbox.
6. Choose OK to continue.
The Pro le page is opened. The following tabs are provided for con guring the data de nition formatting for:
Indentation: add a prede ned number of spaces at the beginning of a statement, clause, or expression
Boolean Expressions: add line breaks and spaces before/after the AND / OR keywords
Entity Name: add line breaks and spaces before/after entity names
Data Source: add line breaks and spaces before/after data sources
Element List: add line breaks and spaces before/after element lists in general
https://help.sap.com/http.svc/dynamicpdfcontentpreview?deliverable_id=22068427&topics=4ed1f2e06e391014adc9fffe4e2… 40/91
12/30/2019
Element List Entries: add spaces before/after element lists entries in general
Break
before
AND / OR
https://help.sap.com/http.svc/dynamicpdfcontentpreview?deliverable_id=22068427&topics=4ed1f2e06e391014adc9fffe4e2… 41/91
12/30/2019
Note
Some of the settings might depend on each other. To make them available, you will need to adjust another setting in
advance.
7. [Optional:] A preview enables you to check the effect of your current setting in your source code. Select the relevant setting
to get an impact of its consequence in the source code.
In the left screen, you can see the current formatting. In the right screen, a preview displays the result of your currently
selected formatting.
Results
The con gured pro le can now be used in the data de nition source editor.
Note
https://help.sap.com/http.svc/dynamicpdfcontentpreview?deliverable_id=22068427&topics=4ed1f2e06e391014adc9fffe4e2… 42/91
12/30/2019
If the data de nition source code is not formatted as de ned, check if the relevant pro le is selected on the DDL Formatter
preference page.
Related Information
Editing Pro les
Prerequisites
You have created or imported a pro le.
Procedure
1. Open the ABAP Development Editors Source Code Editors DDL Formatter preference page.
2. In the Active pro le section, select the relevant pro le from the dropdown listbox of .
If your IDE contains several ABAP projects, the Project Selection dialog is opened. Choose the relevant project.
Note
For further information about the displayed settings, see the Related Information section below.
Results
Your changes are saved and will be considered the next time the DDL formatter is executed.
Related Information
Creating a Pro le
Prerequisites
To import another pro le, you need the corresponding XML le available on the le system.
https://help.sap.com/http.svc/dynamicpdfcontentpreview?deliverable_id=22068427&topics=4ed1f2e06e391014adc9fffe4e2… 43/91
12/30/2019
Procedure
1. Open the ABAP Development Editors Source Code Editors DDL Formatter preference page.
4. Choose Open.
Results
After the import has nished, the imported pro le will be available in the dropdown listbox and automatically selected in the
Active pro le section of the DDL Formatter preference page.
Related Information
Registering and Activating the BAdI Implementation
Exporting Local Pro les
Procedure
1. Open the ABAP Development Editors Source Code Editors DDL Formatter preference page.
When you save the pro le, the XML le name is proposed in accordance with the pro le name to be exported.
4. Choose Save.
Results
The XML le is created and saved in the selected le location.
If you want to overrule the SAP standard pro le at package level with your exported pro le, you can copy its XML content to the
BAdI implementation class.
https://help.sap.com/http.svc/dynamicpdfcontentpreview?deliverable_id=22068427&topics=4ed1f2e06e391014adc9fffe4e2… 44/91
12/30/2019
Related Information
Registering and Activating the BAdI Implementation
Importing Local Pro les
Context
This means, you can specify a pro le in a BAdI implementation to overrule the SAP standard pro le and to uniformly format data
de nition sources grouped in one or more speci c ABAP package(s). Note that you cannot change the SAP standard pro le itself.
3. Export and copy the XML content of your pro le to the BAdI implementation
4. Set the name of your package-speci c pro le in your BAdI implementation and activate it
Related Information
Creating a Pro le
Context
In the back end, create a BAdI implementation and its BAdI implementation class as follows:
Procedure
1. Run transaction SE20.
2. Select the BAdI Name (De nition) radio button and enter SDDIC_ADT_DDLS_PP_CONF in the input eld.
In the Enhancement Spot Display, the Enh. Spot Element De nitions tab for this BAdI is opened.
4. [Optional:] Choose Ctrl + F2 or the check button from the toolbar to ensure that no errors occur in any implementation.
Note
https://help.sap.com/http.svc/dynamicpdfcontentpreview?deliverable_id=22068427&topics=4ed1f2e06e391014adc9fffe4e2… 45/91
12/30/2019
You do not need to create a new implementation if an existing one causes issues.
5. In the BAdI de nitions tree, select the SDDIC_ADT_DDLS_PP_CONF node and then choose the Create BAdI
Implementation button from the toolbar of the Enh. Spot Element De nitions tab.
6. Choose the Create Enhancement Implementation (F8) button to create an enhancement implementation.
7. In the Enhancement Implementation input eld, enter the name of the enhancement implementation to be created.
You can use, for example, SOME_PP_CONF_ENHO. Note that SOME should be replaced with your domain speci c
characterization.
9. Leave the Composite Enhancement Implementation input eld empty and con rm the dialog.
11. Add the relevant ABAP package and transport request for your enhancement implementation.
12. [Optional:] If you are asked to con rm the Enhancement implementation will be created in package to which no switch is
assigned message, select Cont. to con rm.
13. In the list, select the line with the newly created enhancement implementation and choose the Select Speci ed
Enhancement Implementation (Enter) button.
This class is used for the con guration persistence and must implement the IF_DDIC_ADT_DDLS_PP_CONF_BADI
interface. If this class does not exist, it will be created by the system.
https://help.sap.com/http.svc/dynamicpdfcontentpreview?deliverable_id=22068427&topics=4ed1f2e06e391014adc9fffe4e2… 46/91
12/30/2019
Example of a Create BAdI Implementation dialog where you can copy code from the sample class to the new implementation class
19. Choose the Copy Sample Class button to use sample coding for your class to be created.
20. Add the relevant ABAP package and transport request for your class.
The enhancement implementation was saved and the Enh. Implementation Elements tab for this enhancement
implementation is opened.
https://help.sap.com/http.svc/dynamicpdfcontentpreview?deliverable_id=22068427&topics=4ed1f2e06e391014adc9fffe4e2… 47/91
12/30/2019
22. In the BAdI Implementations tree, double-click the Filter Val. node.
The Filter Values screen is opened and displays the two lter combinations of your BAdI implementation.
https://help.sap.com/http.svc/dynamicpdfcontentpreview?deliverable_id=22068427&topics=4ed1f2e06e391014adc9fffe4e2… 48/91
12/30/2019
Note
Comparator 1 must remain '='.
25. Select Continue (Enter) to close the dialog and return to the editor.
Note
In the Filter Combinations of the con guration name, the Value 1 of the PACKAGE lter must remain empty.
27. Enter the name of the package (to be con gured for a speci c data de nition formatting standard) as Value 1.
28. Select Continue (Enter) to close the dialog and return to the editor.
Note
In the Filter Combinations for the package name, the Value 1 of the CONF_NAME lter must remain empty.
Results
The enhancement implementation is con gured but still inactive.
https://help.sap.com/http.svc/dynamicpdfcontentpreview?deliverable_id=22068427&topics=4ed1f2e06e391014adc9fffe4e2… 49/91
12/30/2019
Prerequisites
To paste XML content as a string, you need to open the ABAP Development Editors Source Code Editors Preferences page and
select the Escape text when pasting into string literal checkbox in advance. Otherwise, the XML content cannot be compiled and
your code will become invalid.
Note
This feature is available since ABAP Development Tools (ADT) client version 2.60.
Procedure
1. In ADT, open the ABAP Development Editors Source Code Editors DDL Formatter Preferences page.
2. Open a local pro le with your speci c con guration of the DDL formatter.
3. Export your local pro le into XML format and save it on your le system.
5. In the GET_CONFIGURATION_XML method implementation of the BAdI implementation class, replace the string literal
EXAMPLE_CONFIGURATION_XML with the XML content.
Note
Do not overwrite any hyphens.
Results
Your pro le is used in the BAdI Implementation and will later overrule the SAP standard pro le based on this XML content.
Procedure
1. In ADT, open the BAdI implementation class that you have de ned for the BAdI Implementation.
METHOD IF_DDIC_ADT_DDLS_PP_CONF_BADI~GET_CONFIGURATION_NAME.
result = 'EXAMPLE_CONFIGURATION_NAME' ##NO_TEXT.
...
Note
Do not overwrite any hyphens.
Results
https://help.sap.com/http.svc/dynamicpdfcontentpreview?deliverable_id=22068427&topics=4ed1f2e06e391014adc9fffe4e2… 50/91
12/30/2019
After you have restarted your IDE, the data de nition sources will be formatted according to the package-speci c pro le.
Related Information
De ning the ABAP Language Version of ABAP Programs and Classes
Automatic syntax check: This option is enabled by default for all source code based editors.
Note
If you wish to disable the automatic syntax check, you have to switch off the corresponding setting in the preferences:
ABAP Development Editors Source Code Editors Automatic syntax check .
Explicit syntax check: You can use this option whenever the automatic syntax check is disabled.
Procedure
1. Open the editor with the relevant DDL source code.
2. Click the icon (Check ABAP Development Object) in the toolbar. Alternatively, you can use the keyboard shortcut
Ctrl + F2 .
Results
If errors occur during the check, these will be issued to the Problems view and displayed there as ABAP Syntax Check Problem. In
addition, the code line with the error is labeled with a decorator in the DDL source editor.
https://help.sap.com/http.svc/dynamicpdfcontentpreview?deliverable_id=22068427&topics=4ed1f2e06e391014adc9fffe4e2… 51/91
12/30/2019
Tip
The DDL editor offers corrections to some problems found. In case of missing annotation, for example, you can take advantage
from the quick x for that speci c error item.
Accessing quick fix in the Problems view using the context menu of the error item
Related Information
Activating Data De nitions
https://help.sap.com/http.svc/dynamicpdfcontentpreview?deliverable_id=22068427&topics=4ed1f2e06e391014adc9fffe4e2… 52/91
12/30/2019
Previewing Data Records
Related Information
CDS Graphical Editor
Displaying the Graphical Representation of DDL Source Code
Updating the Graphical Representation of a CDS Entity
Opening a CDS Entity in the Source-Based Editor
Highlighting Used Columns
Navigating Through Data Models
Positioning Objects Automatically in the Graphical Editor
Printing and Exporting Diagrams
Context
This visualization allows you to understand the code implementation much faster as you do not have to read and understand the
code itself.
Procedure
1. Open the context menu on a data de nition.
Tip
Alternatively, you can use the Open With Graphical Editor context menu from a CDS entity.
Results
The CDS Graphical Editor is opened and provides a graphical display of the CDS entity as described in the DDL editor.
Related Information
CDS Graphical Editor
Context
Changes made in the text editor appear immediately in the graphical editor.
Note
Syntax errors appear as parsing errors in the object where the error occurred.
Syntax Errors
Procedure
1. Choose a CDS entity.
2. In the context menu of the CDS entity, choose Open With Graphical Editor .
3. In the context menu of the graphical editor, choose Open DDL Source Editor.
4. Make the required changes to the CDS entity in the source editor.
Procedure
1. Choose a CDS entity.
2. In the context menu of the CDS entity, choose Open With Graphical Editor .
3. In the graphical editor, select the relevant entity and choose Open DDL Source Editor from the context menu.
https://help.sap.com/http.svc/dynamicpdfcontentpreview?deliverable_id=22068427&topics=4ed1f2e06e391014adc9fffe4e2… 54/91
12/30/2019
Procedure
1. Select a user-de ned type.
2. In the context menu of the user-de ned type, choose the Highlight Used Columns option.
Results
The user-de ned type appears highlighted.
https://help.sap.com/http.svc/dynamicpdfcontentpreview?deliverable_id=22068427&topics=4ed1f2e06e391014adc9fffe4e2… 55/91
12/30/2019
Context
If the data model is so large that not all the objects are visible in the graphical editor at once, you can use the Miniature View to
browse the data model.
Procedure
1. Open a CDS entity in a graphical editor.
Tip
To navigate to Quick Access, you can also press CTRL + 3 .
Miniature View
Context
You can still modify the positions of the objects manually. Note that these positions are not persisted.
After modifying the position of the objects manually, you can restore the automatic layout as follows:
Procedure
https://help.sap.com/http.svc/dynamicpdfcontentpreview?deliverable_id=22068427&topics=4ed1f2e06e391014adc9fffe4e2… 56/91
12/30/2019
In the canvas of the graphical editor, choose Auto Layout from the context menu.
Note
Do not select an object representation to open the Auto Layout function.
Results
The Graphical Editor lays out the position of the objects automatically.
Context
You can print or export object diagrams using the graphical editor.
Procedure
1. To print the graphical representation, select the relevant entity and choose Print from the context menu.
The Print preview and preferences dialog is opened. Here you select the relevant printer and print settings.
2. To export the graphical representation as an image le, select the relevant entity and choose Export from the context
menu.
The Export Diagram dialog is opened. Here you can select the relevant area for the graphical representation as well as the
target le format and its size to be generated as an image le.
Context
Use access controls to develop access-control logic for Core Data Services (CDS) entities from SAP NetWeaver AS for ABAP.
Access controls enable you to lter access to data in the database based on static values or conditions based on user data
(classical authorization objects). Use data control language (DCL) to write access controls. If no access control was created and
deployed for the CDS entity, a user who can access the CDS entity has access to all data returned by the entity.
Example
For example, you provide a view of sales orders. You can add a condition that users can only view open sales orders or only
sales orders for companies, which are in the countries that are listed in a classical authorization object.
Tip
We recommend that you protect applications that use CDS entities with classic start authorizations available from SAP
NetWeaver AS for ABAP.
Procedure
1. Create the access control development object.
Edit the source code of the access control just as you would data de nition source code.
Quick xes
Check the syntax of access controls just as you would check the syntax of data de nitions.
Related Information
Creating Access Controls
Editing DDL Source Code
Checking Syntax of DDL Source Code
Activating Data De nitions
Access Controls
https://help.sap.com/http.svc/dynamicpdfcontentpreview?deliverable_id=22068427&topics=4ed1f2e06e391014adc9fffe4e2… 58/91
12/30/2019
Prerequisites
You have the standard developer authorization pro le to create ABAP development objects.
You have created the CDS entities for which you want to restrict access.
Context
An access control is an ABAP development object, which supports standard ABAP Workbench functions such as transport, syntax
check, and activation.
Procedure
1. In your ABAP project, select the relevant package node in the Project Explorer.
New Other ABAP Repository Object Core Data Services Access Control .
3. In addition to the Project and Package, enter the Name and the Description for the access control to be created.
4. Choose Next.
6. Choose Next.
Option Description
https://help.sap.com/http.svc/dynamicpdfcontentpreview?deliverable_id=22068427&topics=4ed1f2e06e391014adc9fffe4e2… 59/91
12/30/2019
Option Description
Use a template. SAP offers example templates for access controls. The template
provides you with example coding for you to modify.
Do not use a template. The tool creates an empty access control for you to code.
8. Choose Finish.
Results
In the selected package, SAP NetWeaver AS for ABAP creates an inactive version of an access control and stores it in the ABAP
Repository. In the Project Explorer, the new access control is added to the Access Controls folder of the corresponding package
node. As a result of this procedure, the access control editor opens. De ne the role for the CDS entity.
Example
The following role grants access to entries of the SFlight_Entity CDS entity, which meet the following conditions:
The ConnID of the entry has the same value as is assigned to the user through the PFCG authorization object S_CONNID
in the CONNID eld.
The @MappingRole annotation must have the value true, so this role is assigned to all users in the system. The value false is
not supported.
Related Information
Access Controls
Editing DDL Source Code
Procedure
In the Project Explorer view, open the context menu of a data de nition and choose Open Data Preview.
Note
In addition, you can also open the Data Preview view from the source code editor of a data de nition. Then choose Open
With Data Preview from the context menu.
Results
https://help.sap.com/http.svc/dynamicpdfcontentpreview?deliverable_id=22068427&topics=4ed1f2e06e391014adc9fffe4e2… 60/91
12/30/2019
The following possibilities might occur:
1. If the CDS View does not require any parameters, the Data Preview displays the result set directly.
2. If the CDS View requires parameters, a dialog to enter parameter values appears:
b. Choose OK.
The Outline view displays parameter values of a CDS View. If you want to modify parameter values, choose the
Parameter option that appears in the Data Preview tool.
Note
If the result set contains less records than you expect, there may be a access control role for the CDS entity that lters the data
returned by the preview.
Related Information
Activating Data De nitions
Context
In the CDS Data Preview, you follow associations to identify related data sources and display their contents.
Procedure
https://help.sap.com/http.svc/dynamicpdfcontentpreview?deliverable_id=22068427&topics=4ed1f2e06e391014adc9fffe4e2… 61/91
12/30/2019
1. In the Project Explorer view, open the context menu of a data de nition and choose Open Data Preview.
Note
In addition, you can also open the Data Preview view from the source code editor of a data de nition. Then choose
Open With Data Preview from the context menu.
Note
If the selected CDS view requires parameters, a wizard for providing parameter values appears.
The Data Preview tool appears and displays the top 100 records by default.
Note
You can also choose > in the breadcrumb bar to follow an association.
3. Choose an association.
https://help.sap.com/http.svc/dynamicpdfcontentpreview?deliverable_id=22068427&topics=4ed1f2e06e391014adc9fffe4e2… 62/91
12/30/2019
Results
The Data Preview displays the result set for the selected association. You can apply lters to the current result set or use the
breadcrumb to navigate to the previous result set. Any lters applied to the result sets are retained.
You can repeatedly follow associations through navigating into the hierarchy de ned by the associations.
You can use the Console option on the Data Preview menu to display the generated Open query for an association. The generated
query uses the CDS database view to display records.
Prerequisites
The SQL dependency can only be calculated for the active version of a data de nition.
Context
You use the Dependency Analyzer to display SQL dependencies of a CDS view. You can also use it to identify, for example,
performance issues.
Procedure
1. In the Project Explorer, select the data de nition that you want to analyze.
2. Open the context menu and choose Open with Dependency Analyzer .
Tip
Alternatively, you can open the same context menu from the DDL source editor of the relevant CDS entity.
The dependencies of data sources involved in the CDS view are calculated. The SQL Dependency Tree tab is opened by
default and displays the result in a tree structure.
3. To display the relevant information from the SQL Dependency Tree tab, proceed as follows:
To get this data for the CDS view: Open the Complexity Metrics subtab. The aggregated statistics are listed there.
To get this data for a speci c data source: Select the relevant SQL Name entry and choose Show Metrics
Complexity from the context menu. The Properties view is opened where the aggregated statistics are then
displayed.
To visualize this data for the CDS view, open the SQL Dependency Graph tab.
https://help.sap.com/http.svc/dynamicpdfcontentpreview?deliverable_id=22068427&topics=4ed1f2e06e391014adc9fffe4e2… 63/91
12/30/2019
Results
Based on the relevant information, you can now, continue your work and improve your data model.
Related Information
Dependency Analyzer
Prerequisites
The data de nition you are currently editing has already been activated.
Context
You want to nd out which annotation values (including the propagated ones) does a CDS view contain and where the individual
annotation values are originated from.
You can open the Active annotations view from the Project Explorer as follows:
Procedure
1. In the Core Data Services ABAP repository tree, open the context menu from the relevant data de nition.
Note
Alternatively, you can open the same context menu from the DDL editor of a CDS view.
Results
The Active Annotations view is opened in the structured mode. It displays all the CDS annotations that are de ned in the CDS
view itself or are inherited from the underlying data sources or data elements.
If the values are inherited from underlying data sources or data elements, you can navigate to these development objects.
Related Information
Active Annotations View
https://help.sap.com/http.svc/dynamicpdfcontentpreview?deliverable_id=22068427&topics=4ed1f2e06e391014adc9fffe4e2… 64/91
12/30/2019
Prerequisites
The CDS View is active.
Context
You want to reproduce how the value for an element annotation was derived.
Procedure
1. In the Project Explorer, select the data de nition you want to analyze.
2. Open the context menu and choose Open With Annotation Propagation .
Tip
Alternatively, you can open the same context menu from the DDL editor of a data de nition.
The Annotation Propagation view is opened and displays by default the values that are propagated for the view
annotations.
Note
If you have placed the cursor on an annotation or an element in the DDL editor, then this element or annotation will be
pre-selected and value propagations for this selection will be displayed.
3. In the <Selection> section, enter the details of the element annotation you want to investigate.
a. In the <Annotations For *> input eld, enter the name of the element.
b. In the <Annotation Filter> input eld, enter the name of the annotation.
Tip
Use the content assist (shortcut Ctrl + Space ) in the input elds to get proposals for the names. Alternatively, you
can choose the <Browse ...> button and search for names.
4. To display the value propagation for the selected element annotation, choose the <Apply> button.
Results
All objects which assign a value to the element annotation are listed in the <Value Propagation> section. The objects are listed in
the order of precedence. The active value of the annotation is highlighted together with information about the contributing object.
Related Information
Annotation Propagation View
Context
https://help.sap.com/http.svc/dynamicpdfcontentpreview?deliverable_id=22068427&topics=4ed1f2e06e391014adc9fffe4e2… 65/91
12/30/2019
You want to get a clear overview, for example, of the elds in a define view statement from which you can select data.
Procedure
1. Open the context menu from the ruler in the DDL source editor.
2. Choose Hide Annotations (Ctrl+Alt+F6) to mask CDS annotations or Hide Comments (Ctrl+Alt+F7) to mask comments
from the source code.
Results
The rows with the comments and annotations disappear from the DDL editor but the row numbering remains as before execution.
Note that the content is not deleted and still available for your CDS object. To display hidden content again, choose the relevant
entry that is highlighted with a tick in the same context menu.
Note
In addition, you can also use the following functionalities to gain a better overview and improve readability of your source code:
Position the cursor on the entity name and press F2 in order to open the Code Element Info view.
Extract the relevant annotations from the select list elements to a metadata extension in order to relocate them.
Related Information
Using Code Folding
Extracting CDS Annotations to a Metadata Extension
Displaying Details in the Element Information Popup and the ABAP Element Info View
Context
Implement unit test for views that contain logical calculations and/or lters. Use unit testing for following entities:
Expressions
Calculations
Conversions
Boolean expressions
in
SELECT list
https://help.sap.com/http.svc/dynamicpdfcontentpreview?deliverable_id=22068427&topics=4ed1f2e06e391014adc9fffe4e2… 66/91
12/30/2019
WHERE
HAVING
ON
ABAP CDS Unit Testing is not suitable for performance testing and for testing properties of CDS entities. For example, do not use
unit testing for:
Naming conventions
Annotation usage
Procedure
1. Consider a CDS view.
@AbapCatalog.sqlViewName: 'zSo_Items_By_1'
@EndUserText.label: 'Aggregations/functions in SELECT list'
@AbapCatalog.compiler.compareFilter: true
define view Salesorder_Items_By_TaxRate
as select from Sales_Order_Item
association [1] to snwd_so as _sales_order on so_guid = _sales_order.node_key
{
so_guid,
coalesce ( _sales_order.so_id, '9999999999' ) as so_id,
currency_code,
sum( gross_amount ) as sum_gross_amount,
tax_rate,
_sales_order
}
group by
so_guid,
_sales_order.so_id,
currency_code,
tax_rate
3. De ne xture methods
"Fixture method class_setup is executed only once in the beginning of the execution of test clas
METHOD class_setup.
"For parameter i_for_entity, specify the CDS view to be unit tested. This will create all the
environment = cl_cds_test_environment=>create( i_for_entity = 'Salesorder_Items_By_TaxRate' ).
ENDMETHOD.
METHOD class_teardown.
environment->destroy( ).
ENDMETHOD.
https://help.sap.com/http.svc/dynamicpdfcontentpreview?deliverable_id=22068427&topics=4ed1f2e06e391014adc9fffe4e2… 67/91
12/30/2019
"Fixture method setup is executed once before each test method execution
METHOD setup.
environment->clear_doubles( ).
ENDMETHOD.
METHOD cuco_1_taxrate_1_item_1_ok.
"Step 1.2 : Use the framework method CL_CDS_TEST_DATA=>create to create the test_data object
test_data = cl_cds_test_data=>create( i_data = sales_orders ).
"Step 1.3 : Use the framework method environment->get_double to the instance of the DOC double
DATA(sales_orders_double) = environment->get_double( i_name = 'SNWD_SO' ).
"Step 1.4 : Insert the testdata into the DOC double object
sales_orders_double->insert( test_data ).
ENDMETHOD.
Note
A developer can create any number of unit test methods to test the CDS.
Identi ers
Identi ers are case-insigni cant; for example, if two view entities are named myView and MYVIEW, respectively, there will
be a naming con ict.
Literals
Only single quotes are allowed for string literals.
Comments
https://help.sap.com/http.svc/dynamicpdfcontentpreview?deliverable_id=22068427&topics=4ed1f2e06e391014adc9fffe4e2… 68/91
12/30/2019
Double slashes ('//') start a comment from the token to the end of the line.
Delimiters
Statements may be terminated with a semi-colon ';' .
Metadata Origin
CDS annotations and their values can be de ned in the CDS view itself or inherited from the underlying data sources or data
elements.
Annotation values are only inherited for elements ( elds and associations) and parameters. Parameters can only inherit from the
corresponding data elements, not from underlying data sources. In addition, CDS annotations de ned in metadata extensions are
merged.
Overview
Annotated Elements: The view, its parameters, elds, and associations, and their active CDS annotations
Origin Data Source: Name of the development object, for example, a data de nition or database table from which the
corresponding annotation is inherited. You can navigate to this object by double-clicking its name.
https://help.sap.com/http.svc/dynamicpdfcontentpreview?deliverable_id=22068427&topics=4ed1f2e06e391014adc9fffe4e2… 69/91
12/30/2019
Origin Data Element: Name of the data element from which the corresponding annotation is inherited. You can navigate to
this object by double-clicking its name.
Enter a lter text in the search eld to display speci c entries in the Annotated Elements column.
Toggle between the at or structured display of the active annotations. The structured mode groups the CDS annotations
by their parent node and is set by default. To switch the display mode, choose the arrow button from the view toolbar and
select the relevant entry.
Related Information
Displaying Annotation Values of an Active CDS View
Use
In a data model, the values of the CDS annotations might derive from different CDS objects. In order to understand how the values
of the used CDS annotations are determined and to visualize this merge process, the Annotation Propagation view is provided.
Overview
Element annotations in data de nitions and metadata extensions are compounded and propagated along the CDS view hierarchy.
In view hierarchies, the element annotation values are propagated from the underlying views to the views above.
In order to reproduce the objects from which propagation has been evaluated, you can open the Annotation Propagation view.
Example
In this example, you as a developer have triggered the Annotation Propagation view with the following selection:
Entity: CDS_View_2
Annotations For*: The element field_4 that is a database eld within the select list.
https://help.sap.com/http.svc/dynamicpdfcontentpreview?deliverable_id=22068427&topics=4ed1f2e06e391014adc9fffe4e2… 70/91
12/30/2019
Note
The input eld Variant is currently not supported.
In this example, the eld represents the name of the CDS object where the annotation is de ned.
Annotation For: Name of the annotated element, parameter, or data source that is speci ed in the Selection area
Annotation Key: Name of the annotation for which you have created the Annotation Propagation view or which lter for
Layer: Numeric value of the @Metadata.layer annotation that was assigned to the contributing metadata extension.
Note
This value is used internally by the ABAP infrastructure to implement the precedence of the annotations speci ed in
metadata extensions.
Entity Name: Name of the contributing CDS entity if the object is a CDS view, CDS table function, or metadata extension.
This column is empty if the contributing object is not a CDS object.
Switch Status. The following columns provide information about the Switch state of a metadata extension:
If OFF is displayed, then the metadata extension does not contribute to the metadata of a CDS entity.
If a Switch is not assigned to the metadata extension, then the metadata extension is always enabled. In this
case, the entries in the Switch Package and Switch Name columns are empty.
Switch Package: Name of the corresponding metadata extension's package if a Switch is assigned to the metadata
extension
Switch Name: Name of the Switch which is assigned to the metadata extension
Note
This value is used SAP-internally only to implement the precedence of the annotations speci ed in metadata
extensions.
Annotations can be de ned/inherited in/from data de nitions/metadata extensions. For a given layer or a CDS variant
annotations might be inactive. If so, they are displayed in grey and not considered for evaluation. Active annotations are displayed
in black.
https://help.sap.com/http.svc/dynamicpdfcontentpreview?deliverable_id=22068427&topics=4ed1f2e06e391014adc9fffe4e2… 71/91
12/30/2019
metadata extensions.
Related Information
Annotation Propagation
Displaying Annotation Values of an Active CDS View
Analyzing Annotation Propagations
Metadata Extensions
Switch Framework
Dependency Analyzer
The Dependency Analyzer evaluates the relationships and complexity from a CDS entity with regards to its SQL de nition.
You use the Dependency Analyzer to investigate which database objects (such as CDS database views, database tables, database
views, and table functions) are used in your CDS view. In addition, it helps you to understand SQL dependencies and complexity
that might negatively affect the performance of your query.
The Complexity Metrics tab displays a statistical summary of selected key gures (such as used data sources, SQL
operations, function calls, and expressions).
Related Information
Analyzing Dependencies in Complex CDS Views
Use Cases
You as a developer open the SAP Dependency Tree tab in the following cases:
You want to edit a CDS view: You want to check the top to bottom SQL dependencies of a CDS view.
You want to reuse a CDS view: You want to understand the dependencies of a CDS view before reusing it.
If there are performance or activation issues, you want to nd out which database object may be the cause.
Overview
The data sources involved are determined recursively and the result is displayed in a tree structure. The following database
objects are possible as data sources:
Database view
https://help.sap.com/http.svc/dynamicpdfcontentpreview?deliverable_id=22068427&topics=4ed1f2e06e391014adc9fffe4e2… 72/91
12/30/2019
External view
Note
External views are used to access the SAP HANA-based views in the ABAP source code. To access this kind of data
model, your ABAP systems needs to be connected with a SAP HANA database.
Database table
SQL Relation: How a database object may be related to its parent object.
Example
The following relations might be displayed:
Database Object: Status if the corresponding artifact physically exists in the database. Then, the value true is displayed.
Note
If the eld is empty, the corresponding artifact does not exist in the database.
Access Control: Status of the object's access controls with respect to analyzed CDS views
https://help.sap.com/http.svc/dynamicpdfcontentpreview?deliverable_id=22068427&topics=4ed1f2e06e391014adc9fffe4e2… 73/91
12/30/2019
The following status are displayed:
De ned: The access control is de ned for the CDS view as root node of the dependency tree.
Masked: The access control is de ned for the CDS view(s) as a sub node of the dependency tree.
[Empty]: The database object is no CDS view and provides therefore no information about access controls.
Note
To nd the access control that is de ned, choose Open Other from the context menu of the relevant Defined or
Masked status.
Additional Functionality
In addition to displaying dependencies, you can perform the following functions:
Toolbar
To refresh the dependency tree, for example, after modi cations have been made and the data de nition has been
activated, choose the Refresh icon from the toolbar.
To expand/collapse all nodes in the tree structure, choose the Expand All or Minimize All icons from the toolbar.
To export the graph as PNG le, choose the icon from the toolbar.
Tree
To navigate to the listed data sources through double-click or using the context menu.
To search for objects, enter the relevant name in the Find eld of the search toolbar. If the search toolbar is not displayed,
choose the Show Search icon from the graph toolbar to make it available.
Context Menu
To display the complexity metrics of a CDS or database object, select the relevant object and choose Show Complexity
Metrics from the context menu. Then, the Properties view opened where the relevant information is displayed.
Related Information
SQL Dependency Graph
Complexity Metrics
External Views
Use Case
You want to visualize the dependencies of a complex CDS view and its neighboring objects in order to investigate their
relationships.
Overview
https://help.sap.com/http.svc/dynamicpdfcontentpreview?deliverable_id=22068427&topics=4ed1f2e06e391014adc9fffe4e2… 74/91
12/30/2019
The SQL Dependency Graph tab contains the same information as the SQL Dependency Tree tab but it visualizes the data model
in a graph. This means the closer the nodes representing the objects are, the closer is their relationship. Hierarchies are
represented by the reference to objects on the subsequent level. Objects, that are on the same level, are, if possible, displayed on
the same imaginary line. Relations are displayed as circles.
Note
The coloring of the elements used in the SQL Dependency Graph is prede ned. To adapt the coloring, open the ABAP
Development Graphical Tools Dependencies Analyzer preference page and assign another color to the element.
Additional Functionality
In addition to displaying dependencies, you can perform the following functions:
Toolbar
To toggle between the SQL Name and Entity Name in the graph, select the icon from the toolbar.
To export the graph as a PNG le, choose the icon from the toolbar.
To maximize or minimize the current position, choose the relevant value from the zoom dropdown listbox in the toolbar.
Graph
To display general and statistical information about a CDS or database object in the tooltip popup, mouse over the relevant
object.
To follow the dependencies of neighboring objects, select the corresponding node. Then, the contrast of the relevant
dependencies is highlighted?.
https://help.sap.com/http.svc/dynamicpdfcontentpreview?deliverable_id=22068427&topics=4ed1f2e06e391014adc9fffe4e2… 75/91
12/30/2019
To search for objects, enter the relevant name in the Find eld of the search toolbar. If the search toolbar is not displayed,
choose the Show Search icon from the graph toolbar to make it available.
To display the complexity metrics of a CDS or database object, select the relevant one and choose Show Complexity
Metrics from the context menu. The Properties view will open where the relevant information is displayed.
You can highlight the elements of the graph in the context of their interdependencies. You can mask the following
attributes:
Object type
Availabilityof an existing database object sion the database (available as of SAP NetWeaver AS for ABAP 7.51
innovation package SP00)
Availability of an access control (available as of SAP NetWeaver AS for ABAP 7.51 innovation package SP01)
To highlight them, choose Highlight from the context menu on the white area of the graph. Then select the relevant entries
from the submenus of one or more attributes.
Note
If you select one or more entries
from the submenu of the same attribute, all relevant elements will be highlighted that match at least one of the
selected entries.
from several submenus of different attributes, only those elements will be highlighted that match the selection
from the submenu of the same attribute and from the submenus of the other submenus.
Outline
To navigate within large graphs, move the highlighted area in the Outline view as required.
Related Information
SQL Dependency Tree
Complexity Metrics
Complexity Metrics
The Complexity Metrics tab enables you to check CDS views regarding performance issues.
Use Case
You want to check the characteristics that in uence the performance of your CDS view.
Overview
This tab summarizes statistical information about a CDS view in the following sections:
Used Data Sources: List of the aggregated number of database objects that depend on the selected CDS view
Note
Each usage is counted separately. Identical data sources are not grouped.
SQL Operations: List of the aggregated number of the SQL operations that might be most relevant for performance issues
https://help.sap.com/http.svc/dynamicpdfcontentpreview?deliverable_id=22068427&topics=4ed1f2e06e391014adc9fffe4e2… 76/91
12/30/2019
Performance Related Function Calls and Operations: List of the aggregated number of expressions and function calls
Related Information
SQL Dependency Tree
SQL Dependency Graph
ABAP CDS - SELECT, Prede ned Functions (ABAP Keyword Documentation)
The editor allows you to understand the code implementation much faster as you do not have to read and understand the code
itself.
In the CDS Graphical Editor, the following graphical representations of CDS entities are provided:
Symbol Description
Represents an entity
https://help.sap.com/http.svc/dynamicpdfcontentpreview?deliverable_id=22068427&topics=4ed1f2e06e391014adc9fffe4e2… 77/91
12/30/2019
Symbol Description
Note
This line indicates the relationship between entities. The
association name appears on the line. It also displays the
cardinality if you have de ned cardinality for the association.
Indicates a union
The CDS Graphical Editor provides you with the following options:
To make changes to the CDS entities in the DDL source code editor and view the changes in the graphical editor
Related Information
Working with the Graphical Editor
Glossary
Access Control
ABAP development object that is used to de ne authorizations for CDS entities
An access control allows you to limit the results returned by a CDS entity to those you authorize a user to see.
An CDS database view is generated in the ABAP Dictionary after activation of the data de nition. The structure of a CDS database
view is de ned in a CDS entity. A CDS database view is a technical representation of the CDS entity.
CDS Entity
Part of a data de nition
https://help.sap.com/http.svc/dynamicpdfcontentpreview?deliverable_id=22068427&topics=4ed1f2e06e391014adc9fffe4e2… 78/91
12/30/2019
The de nition of a CDS entity is introduced with the DEFINE VIEW statement. A CDS entity is used to specify the structure of a
CDS database view.
http://xunitpatterns.com/unit%20test.html
http://xunitpatterns.com/SUT.html
Clones
Creating a temporary clone (copy) of the CUT in the same DB schema.
For all purposes, this clone serves as the CDS entity under test. The logic implemented in the original CDS entity is preserved in
the clone but the depended-on components are replaced by the corresponding Test Doubles that are created by the CDS Test
Double Framework.
Data De nition
ABAP development object that is used to de ne a CDS view entities
A data de nition is created in ABAP Repository using a wizard of ABAP Development Tools.
DCL Editor
Text-based editor for editing DCL sources
The DCL editor is part of ABAP Development Tools and allows you to de ne the role or access policy for the CDS entity.
DDL statements are used to create and delete the entities of a relational database. In AS ABAP, DDL is integrated into ABAP
Dictionary.
DDL Editor
Text-based editor for editing development objects containing DDL such as data de nitions and metadata extensions
https://help.sap.com/http.svc/dynamicpdfcontentpreview?deliverable_id=22068427&topics=4ed1f2e06e391014adc9fffe4e2… 79/91
12/30/2019
The DDL editor is part of ABAP Development Tools.
Metadata Extension
ABAP development object that is used to annotate CDS entities with metadata
A metadata extension can be used by customers for annotating CDS entities without modi cations.
Test Doubles
Use Test Doubles for writing a test in which you cannot use a real DOC. The Test Doubles does not behave exactly like real
DOC; it merely provides the same API as the real one for CUT to execute the operations.
The following table gives you an overview of the released ADT versions and ABAP back ends:
SAP NetWeaver 7.4 SAP NetWeaver 7.5 SAP NetWeaver AS for ABAP 7.51 ABAP Development Tools (Client)
innovation package
https://help.sap.com/http.svc/dynamicpdfcontentpreview?deliverable_id=22068427&topics=4ed1f2e06e391014adc9fffe4e2… 80/91
12/30/2019
SAP NetWeaver 7.4 SAP NetWeaver 7.5 SAP NetWeaver AS for ABAP 7.51 ABAP Development Tools (Client)
innovation package
The SQL Dependency Tree now displays the status (Defined, Masked, None) of Access Controls de ned for the selected CDS
object.
You can lter for attributes of data sources in order to highlight relevant data sources in the graph. The available attributes are
object type, SQL relation, and database object. As of now, you can also lter for dependencies of access controls.
To open this graph, choose Open With Dependency Graph from the context menu of the relevant data de nition or the editor.
If annotations of a given layer or a CDS variant are inactive or no more considered for evaluation, they are now displayed in grey.
Only active annotations are displayed in black.
https://help.sap.com/http.svc/dynamicpdfcontentpreview?deliverable_id=22068427&topics=4ed1f2e06e391014adc9fffe4e2… 81/91
12/30/2019
You can now use the DDL formatter to de ne your own local pro les or use the SAP standard pro le to format data de nitions and
metadata extensions when saving. Everything is precon gured if you use the SAP standard pro le.
You can enable/disable a local pro le or the SAP standard pro le on the ABAP Development Editors Source Code Editors DDL
Formatter preference page.
You can trigger the DDL formatter at any time using the:
Shortcut Shift + F1
Format DDL on save checkbox on the DDL Formatter preference page to trigger formatting automatically whenever you
save.
You can now create HTTP links for data de nitions, metadata extensions, and access controls in order to share them with other
developers of your company.
For more information, look here: Sharing and Opening a Link to a Development Object
You can now also duplicate data de nitions, metadata extensions, and access controls.
For more information, see here: Copying and Duplicating Source Code Based Objects
In the Project Explorer, the names of the folders – where the CDS objects are grouped and displayed – have been renamed.
In the Core Data Sources folder, the following folder names are now used:
Metadata Extensions for adding customer-speci c requirements to SAP's CDS entities without modi cations
https://help.sap.com/http.svc/dynamicpdfcontentpreview?deliverable_id=22068427&topics=4ed1f2e06e391014adc9fffe4e2… 82/91
12/30/2019
You can now enable automatic unit testing of CDS views using the CDS Test Double Framework.
Using the ABAP Test Cockpit to Check Data De nitions and Metadata Extensions
You can now use the ATC tools to check CDS objects such as data de nitions and metadata extensions. There have been added
speci c checks by SAP.
To perform the ATC for a CDS object, select the relevant one in the Project Explorer and choose Run As ABAP Test Cockpit
(Ctrl+Shift+F2) from the context menu. The ATC Problems view is then opened and displays the check result.
Metadata Extensions
Extenting CDS Entities Through Metadata Extensions
Metadata extenstions are new development objects that are saved in the ABAP Repository and can be transported within your
ABAP system landscape.
You specify metadata extenstions to extend and to adapt the behavior of CDS entities with customer-speci c metadata using CDS
annotations.
This enables you to specify your own annotations in metadata extensions to overwrite metadata used in data de nitions without
causing modi cations. When creating metadata extensions, you can use a set of prede ned code templates.
Metadata Extensions
You can extract one or more annotations – that are previously used in a data de nition – to a new metadata extension.
To perform an extraction, choose Source Code Extract Metadata Extension from the context menu of the data de nition from
where you want to relocate CDS annotations to a new metadata extension. A creation wizard is then opened to select the relevant
annotations. Note that you can only extract those annotations that are allowed to be used in metadata extensions.
For more information, see here: Extracting CDS Annotations to a Metadata Extension
The Annotation Propagation view is a tabular list to display how the value for an element annotation has been derived.
It provides the value of a CDS annotation and from which CDS entity or metadata extension it has been inherited. This enables you
to understand how the metadata was merged for a CDS View.
https://help.sap.com/http.svc/dynamicpdfcontentpreview?deliverable_id=22068427&topics=4ed1f2e06e391014adc9fffe4e2… 83/91
12/30/2019
To open the Annotation Propagation view, choose Open With Annotation Propagation from the context menu of a data
de nition or metadata extension.
You can now open the Active annotations view to display the CDS annotations that are used for an active CDS view.
Annotated Elements: Group, name, and value name of the inheriting annotation
Original Data Element: Name of a data element from which the origin value is inherited
To open the Active Annotation view, choose Open With Active Annotations from the context menu of a data de nition.
You can now use the Dependency Analyzer to evaluate the relationships and complexity of a CDS entity with regards to its SQL
de nition.
To perform the Dependency Analyzer, choose Open With Dependency Analyzer from the context menu of a data de nition.
Dependency Analyzer
https://help.sap.com/http.svc/dynamicpdfcontentpreview?deliverable_id=22068427&topics=4ed1f2e06e391014adc9fffe4e2… 84/91
12/30/2019
not have to read and understand the code.
Sample Code
@ClientDependent: true
Tool Support
Keywords
Annotations
Data types in parameter de nitions and in eld de nitions (both built-in and DDIC types)
Navigation to (F3)
Implementing class
Implementing method
Table functions (triggered with F2 in the DDL source itself, not in the ABAP class)
https://help.sap.com/http.svc/dynamicpdfcontentpreview?deliverable_id=22068427&topics=4ed1f2e06e391014adc9fffe4e2… 85/91
12/30/2019
DDIC types used in eld/parameter de nitions
Example:
Sample Code
@AbapCatalog.sqlViewAppendName: 'DEMO_CDS_EXTENS'
extend view demo_cds_original_view with demo_cds_view_extension
{ spfli.distance,
spfli.distid as unit };
Tool Support
Including associations of the base view when triggering Insert all elements in the code completion in the EXTEND VIEW
Navigation from the usage of the association in the EXTEND VIEW to its de nition in the base view (CTRL + click) or its
target (CTRL + click )
Displaying the associations that have been added in the EXTEND VIEW in the element info of the base view.
De ning ON Conditions
You can now apply a wizard for de ning ON conditions in JOIN clauses and ASSOCIATION de nitions of your CDS view de nition.
Dependency Analyzer
https://help.sap.com/http.svc/dynamicpdfcontentpreview?deliverable_id=22068427&topics=4ed1f2e06e391014adc9fffe4e2… 86/91
12/30/2019
When implementing the view on view pattern, the relations between the resulting data sources can become very complex. The
Dependency Analyzer aims to give the CDS developer a better overview of the complexity of the SQL behavior so that this
complexity might be reduced and/or super uous JOINs might be found.
As a part of CDS View Building tools, you can now create DCL sources as a new development object that is used to de ne
authorizations for CDS entities.
https://help.sap.com/http.svc/dynamicpdfcontentpreview?deliverable_id=22068427&topics=4ed1f2e06e391014adc9fffe4e2… 87/91
12/30/2019
The new Data Preview tool provides you with test environment so that you can verify the output (result set) of a CDS view.
https://help.sap.com/http.svc/dynamicpdfcontentpreview?deliverable_id=22068427&topics=4ed1f2e06e391014adc9fffe4e2… 88/91
12/30/2019
The Data Preview tool allows you to display the result set for of an associated CDS view.
SQL Console
You can use the SQL Console tool to write an SQL statement and analyze the query performance. It enables you to execute
arbitrary SELECT statements on the database without writing any ABAP report.
To open the SQL Console tool, select the relevant ABAP Project in the Project Explorer. Then open the context menu of the
project and choose the SQL Console menu item.
Tip
Aletrnatively, you can open the SQL Console wrom within the Data Preview tool. In that case, the data preview automatically
generates you the corresponding SQL statement according to your lter settings.
https://help.sap.com/http.svc/dynamicpdfcontentpreview?deliverable_id=22068427&topics=4ed1f2e06e391014adc9fffe4e2… 89/91
12/30/2019
SQL Console
Related Information
Working with SQL Console
The editor supports now an extended set of keywords in CDS views for:
De ning associations within the CDS views and exposing them in projects lists
Code Pushdown
The editor supports now an extended set of keywords in CDS views for:
Aggregation functions
CASE statements
https://help.sap.com/http.svc/dynamicpdfcontentpreview?deliverable_id=22068427&topics=4ed1f2e06e391014adc9fffe4e2… 90/91
12/30/2019
SQL functions
Arithmetic expressions
https://help.sap.com/http.svc/dynamicpdfcontentpreview?deliverable_id=22068427&topics=4ed1f2e06e391014adc9fffe4e2… 91/91