CDS Views Interview Questions
CDS Views Interview Questions
Ans) To take advantage of SAP HANA for application development, SAP introduced a new data modeling
infrastructure known as Core data services.
With CDS, Data models are defined and consumed on database server rather than on application server.
Ans) It pushes the code to the database layer from the application layer. There in the database layer it
performs calculations and bring back the relevant data to the application layer.
Q) What is DDL?
DDL statements are SQL statements that are used to define the data structure in a database (DDL = Data
Definition Language). In the SAP MaxDB database system, DDL statements are controlled by the
transaction concept.
CDS Views are defined in a source DDL and at activation time it generates two objects :
SQL View : this is an invisible object in the ABAP dictionary that cannot be modified.
CDS View
The simplest form of CDS View is the projection, i.e. a selection of fields from a single table. The name of
a view specified in @ABAPCatalog.sqlViewName must be different from the name of the CDS entity and
their names cannot exceed sixteen characters.
Basic Views: These are the building blocks of data modeling, directly connecting to database tables and
other views.
Composite Views: They merge multiple basic views and can include more complex operations like joins
or unions.
Consumption Views: Designed for specific usage scenarios like analytics or reporting, often optimized
for efficient data handling.
Interface Views: They act as a bridge between different views or external systems, simplifying the
underlying complexity.
Annotations in CDS views are metadata tags that provide additional information about the view's
structure and behavior. They are crucial for
Defining Metadata: Annotations provide essential information about the view, such as its SQL view
name and labels.
Enhancing User Interfaces: Annotations control how data is presented in UI5 applications, including
selection fields, line items, and field groups.
Managing Authorizations: Annotations specify authorization checks and secure data access.
Enabling Analytics and Data Extraction: Annotations facilitate the use of views in analytical applications
and enable efficient data extraction for reporting purposes.
1. General Annotations
@EndUserText.label: Provides a label for the CDS view. Example: @EndUserText.label: 'Sales
Order View'
@VDM.viewType: Specifies the type of view in the Virtual Data Model (VDM). Example:
@VDM.viewType: #BASIC
2. UI Annotations
These annotations control the behavior and appearance of CDS views in UI5 applications.
@UI.lineItem: Marks a field to be displayed in a line item list. Example: @UI.lineItem: [{position:
20}] <br> OrderAmount
3. Analytics Annotations
These annotations define how data can be extracted from the CDS view.
5. Fiori Annotations
@OData.publish: Publishes the CDS view as an OData service. Example: @OData.publish: true
@OData.action.name: This annotation is used to define custom actions or functions that can be
performed on entities exposed by the OData service. It specifies the name of the action or
function and associates it with a specific entity type. Example: @OData.Action.name:
'CancelOrder'
6. Association Annotations
7. Authorization Annotations
8. Performance Annotations
9. Field Annotations
These annotations define properties and behaviors of individual fields in a CDS view.
Here is a sample CDS view that includes different annotations to show how they are used:
@AbapCatalog.sqlViewName: 'ZV_SALES_ORDER'
@AccessControl.authorizationCheck: #NOT_REQUIRED
@ObjectModel.usageType.dataClass: "Transactional"
@ObjectModel.usageType.sizeCategory: "Medium"
@ObjectModel.usageType.serviceQuality: "High"
@VDM.viewType: #BASIC
@Analytics.dataCategory: #CUBE
@Analytics.dataExtraction.enabled: true
@OData.publish: true
created_at,
changed_at
Conclusion
SAP ABAP CDS views, with annotations, offer a powerful way to create and manage complex data
models directly in the database. Annotations enhance the functionality, behavior, and user interface of
CDS views. By understanding and using different types of annotations, developers can create highly
optimized, secure, and user-friendly data models that meet various business needs. Annotations in CDS
views provide a comprehensive and flexible approach to data modeling in SAP, covering general
properties, UI integration, analytics, data extraction, associations, authorization, and performance
optimization.
Note CDS doesn’t support Full Outer Join. The alternative is to use Union. With the help of Union we can
achieve full Outer Join.
Ans) CDS is supported by All Databases, whereas AMDP is supported by only HDB( Hana Database)
Which is the mandatory annotation which is required in order to create the CDS view?
Can CDS be buffered like a Table?
SQL View name can be without Y 0r Z whereas CDS view name cannot be without Y or Z.
What is a parametrized CDS?
Ans) It comes into the picture when you have to filter the data from CDS
Association in CDS
Associations in CDS views define relationships between entities or views. They allow you to express links
between data based on keys or other conditions. Associations enable navigation from one entity to
another, providing a convenient way to access related data.
2 types of Association