0% found this document useful (0 votes)
4 views

CDS Views Interview Questions

Uploaded by

Sundaran Nair
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

CDS Views Interview Questions

Uploaded by

Sundaran Nair
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 11

Q) What is CDS ?

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.

Q) What is meant by Code Pushed Down?

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.

Common examples of DDL statements include CREATE, TRUNCATE,ALTER, and DROP

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.

Q) What are the different types of CDS views in SAP ABAP?


Ans) There are 3 types of ABAP CDS views available in SAP and they are basic views, composite views
and consumption views. Note: ABAP CDS views are similar to Hana Views (attribute views, analytic views
and calculation views) but they are database independent and lie on the Application layer.

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.

Q) What are the importance of annotations in CDS views ?

Ans) The importance of annotations in CDS views

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.

Optimizing Performance: Performance-related annotations help in fine-tuning data retrieval and


processing.

Enabling Analytics and Data Extraction: Annotations facilitate the use of views in analytical applications
and enable efficient data extraction for reporting purposes.

Below are the various type of Annotations currently available in S4/HANA.

1. General Annotations

These annotations provide general properties for the CDS view.

 @AbapCatalog.sqlViewName: Specifies the SQL view name. Example:


@AbapCatalog.sqlViewName: 'ZV_SALES_ORDER'
 @AbapCatalog.compiler.compareFilter: Ensures filter criteria are considered during view
comparison. Example: @AbapCatalog.compiler.compareFilter: true

 @AccessControl.authorizationCheck: Defines the level of authorization checks required.


Example: @AccessControl.authorizationCheck: #NOT_REQUIRED

 @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.selectionField: Marks a field as a selection field. Example: @UI.selectionField: [{position:


10}] <br> CustomerID

 @UI.lineItem: Marks a field to be displayed in a line item list. Example: @UI.lineItem: [{position:
20}] <br> OrderAmount

 @UI.fieldGroup: Groups fields together. Example: @UI.fieldGroup: [{qualifier: 'General',


position: 10}] <br> OrderDate

 @UI.identification: Marks a field to be used as an identification field. Example:


@UI.identification: [{position: 1}] <br> SalesOrderID

3. Analytics Annotations

These annotations define analytical properties of the CDS view.

 @Analytics.dataCategory: Specifies the type of analytical data. Example:


@Analytics.dataCategory: #CUBE

 @Analytics.dataExtraction.enabled: Enables data extraction for analytics. Example:


@Analytics.dataExtraction.enabled: true

 @Analytics.query: Defines the view as a query for analytical purposes. Example:


@Analytics.query: true

 @AnalyticsDetails.query.axis: Specifies the axis (rows or columns) for a field in an analytical


query. Example: @AnalyticsDetails.query.axis: #ROWS

4. Data Extraction Annotations

These annotations define how data can be extracted from the CDS view.

 @ Analytics.dataExtraction.delta.byElement: Enables delta handling by specific elements.


Example: @Analytics.dataExtraction.delta.byElement: true
 @Analytics.dataExtraction.delta.changeDataCapture: Specifies fields for change data capture
in delta handling. Example: @Analytics.dataExtraction.delta.changeDataCapture:
{ creationDateElement: 'CreatedAt',changeDateElement: 'ChangedAt' }

5. Fiori Annotations

These annotations simplify the use of CDS views in Fiori applications.

 @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

These annotations define relationships between CDS views.

 @ObjectModel.association.type: Defines the type of association. Example:


@ObjectModel.association.type: #TO_COMPOSITION_CHILD

 @ObjectModel.association.usage: Specifies how the association is used. Example:


@ObjectModel.association.usage: #TO_COMPOSITION_ROOT

7. Authorization Annotations

These annotations manage authorization and access control.

 @AccessControl.authorizationCheck: Defines the level of authorization checks required.


Example: @AccessControl.authorizationCheck: #NOT_REQUIRED

 @ObjectModel.securedBy: Specifies fields used for authorization checks. Example:


@ObjectModel.securedBy: { element: 'AuthorizationField' }

8. Performance Annotations

These annotations optimize the performance of the CDS view.

 @ObjectModel.usageType: Defines how the CDS view is used to optimize performance.


Example: @ObjectModel.usageType: { analytics.query: true, dataClass: #ANALYTICAL }

 @ObjectModel.transactionalProcessingEnabled: Enables transactional processing. Example:


@ObjectModel.transactionalProcessingEnabled: true

 @ObjectModel.usageType.serviceQuality: This annotation describes the expected performance


quality of the CDS view, which is vital for developers and users to understand how the view
behaves under different conditions. Example:@ObjectModel.usageType.serviceQuality: "High"

 @ObjectModel.usageType.dataClass:This annotation specifies the type or category of data


contained within the CDS view, aiding developers in understanding the nature of the data being
accessed or manipulated. Example:@ObjectModel.usageType.dataClass: "Master data"
 @ObjectModel.usageType.sizeCategory:This annotation categorizes the size or volume of data
represented by the CDS view, helping developers understand the scale at which the view
operates. Example:@ObjectModel.usageType.sizeCategory: "Large"

9. Field Annotations

These annotations define properties and behaviors of individual fields in a CDS view.

 @ObjectModel.foreignKey.association: Specifies the association used for foreign key


relationships. Example: @ObjectModel.foreignKey.association: 'AssociationName'

 @Semantics.amount.currencyCode: Specifies the currency code associated with an amount


field. Example: @Semantics.amount.currencyCode: 'CurrencyField'

 @Semantics.quantity.unitOfMeasure: Specifies the unit of measure associated with a quantity


field. Example: @Semantics.quantity.unitOfMeasure: 'UnitField'

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

@EndUserText.label: 'Sales Order View'

@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

define view ZC_SalesOrder as

select from sales_order

@UI.selectionField: [{position: 10}] key sales_order_id,

@UI.lineItem: [{position: 20}] customer_id,

@UI.fieldGroup: [{qualifier: 'General', position: 10}] order_date,

@UI.identification: [{position: 1}] order_amount,

@AnalyticsDetails.query.axis: #ROWS sales_order_id,


@AnalyticsDetails.query.axis: #ROWS customer_id,

@ObjectModel.association.type: #TO_COMPOSITION_CHILD association [0..*] to ZC_Customer


as Customer on $projection.customerid = Customer.customerid,

@ObjectModel.foreignKey.association: '_Customer' customer_id,

@Semantics.amount.currencyCode: 'Currency' order_amount,

created_at,

changed_at

where changed_at > 20230101 and changed_at <= 20231231

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.

Is CDS and AMDP supported by All Databases?

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.

Association is Join on Demand

2 types of Association

1) ADHoc Association & 2) Exposed Association

You might also like