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

CDS - Interview Questions

Interview Questions on SAP CDS.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
75 views

CDS - Interview Questions

Interview Questions on SAP CDS.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 12

Question #1: What is SAP HANA CDS view?

Answer:

Core Data Services (CDS) as the name suggests, is a service directly by HANA core. To present CDS in a
very understandable manner, CDS is a view of one or multiple tables and can be enriched with metadata
which makes it even more useful than just a pile of dumb data. Just to mention some pointers which will
help to understand why CDS framework is more useful:

 CDS artifacts are present and execute on database(HANA or other) layer. This strategy is called code
push down where Application layer logic can be easily moved to Database layer for execution. This
has many performance advantages if used carefully.
 Can be assigned to authorization object and visibility can be easily controlled
 CDS view can be easily consumed by oData service
 Can provide semantic information to each field which is particularly helpful when information is to be
displayed on browser
 CDS can be buffered just like a transparent table
 Can be enabled for Search
 CDS can be used to define Data Hierarchy and relationships which is particularly helpful is navigation
and drill downs

HANA is in memory database and performance capabilities can be leveraged only when calculations are
done in-memory. If the business logic is fully written on the application layer and this defeats the purpose
of in-memory computation. New HANA artifacts like CDS, AMDP(ABAP Managed Database
Procedure), CTE(Common Table Expressions) etc. fully complement code push down and are designed
for performance optimization.

Question #2: Which three TADIR objects/artifacts are created on activation of a ABAP HANA
CDS?

Answer:

The artifacts created during CDS creation are:

1. DDLS(Data Definition Language Source) – We enter DDLS name along with package name and
Description
2. VIEW(A structure which can be seen in SE11) – is mentioned with annotation
@AbapCatalog.sqlViewName. Just press Control and Click on View name and it leads to SE11
structure
3. STOB(Structured Object) – is mentioned with ‘define view’ or ‘extend view’ syntax.

Question #3: How many types of ABAP HANA CDS views are there?

Answer:

CDS view is evolving and new features are added with almost every technical release.
1. CDS view
1. Basic CDS view
2. CDS View with Join
3. CDS View with Association
4. CDS View with Parameters
5. Extended CDS view
6. CDS View on View
2. Table Function
1. Normal Table Function
2. Table Function with Parameters
3. Abstract Entity
1. Normal Abstract Entity
2. Abstract Entity with Parameters

Question #4: What is Association and Path expression in ABAP HANA CDS?

Answer:

Association

Association is different than join in that sense that association defines how two entities are connected to
each other. It is sometimes understood as “Conceptual Thinking” also because its nature of linking
entities rather than joining them directly. The join may be the next step once the association is defined.

Cardinality

In database design, the cardinality or fundamental principle of one data aspect with respect to another is a
critical feature. The relationship of one to the other must be precise and exact between each other in order
to explain how each aspect links together.

In the relational model, tables can be related as any of “one-to-many”, “many-to-many” “one-to-zero-or-
one”, etc.. This is said to be the cardinality of a given table in relation to another.
In terms of SAP:

 A [1..1] B means that for every row of A, there is a unique row in B and vice versa
 A[0..1] B or just A [1] B means that B may have a record for which there no source information in A.
 A [0..*] B means that B may have many records for which there no source information in A.

Path Expressions

Path expressions identify an object by describing how to navigate to it to objects via steps/route. For
example, the path expression Object.Employee.Address.ZipCode can refer to Zip Code of particular
Employee’s address. Of course, this relationship should be established beforehand using
association/cardinality to use this kind of Path to access particular information.

Question #5: Can ABAP HANA CDS view have a tabular parameters (as of ABAP 7.52)?

Answer:

No, CDS view takes only scalar parameters (till ABAP release 7.52).

Question #7: What are Table Functions with CDS?

Answer:

A Table function is an integral part of CDS evolution which challenges CDS to do more! It is essentially
a Code push down mechanism just like a CDS entity. We call Table function a CDS Data Definition
Language(DDL) which uses syntax DEFINE TABLE FUNCTION. Read more HERE.

Question #8: Name at least 2 CDS session variables?

Answer:

As of ABAP 7.51, CDS framework provides some runtime system variables which can be readily used to
make CDS more optimal and feature-rich. These session variables sometimes also discard the need of
parameterization of CDS view.

 $session.client is runtime SAP client which is equivalent to sy-mandt in AS ABAP


 $session.system_date is current system date and works same as sy-datum in AS ABAP
 $session.system_language works very similar to sy-langu in AS ABAP
 $session.user is essentially same as sy-uname in AS ABAP

Question #9Compare the performance of New Open SQL, CDS, AMDP and CTE?

Answer:

You may find comparison HERE.

Performance Comparison: New Open SQL vs CDS vs AMDP vs CTE


It is a very common question nowadays, which one to chose when hitting the database? Option candidates
are New Open SQL, CDS(Core Data Services), AMDP(ABAP Managed Database Procedure) or
CTE(Common Table Expression). They all are designed for new enhanced ABAP and they all are made
for delivering performance. Moreover, all of them do code push down!

Disclaimer: Use this article and its derived conclusion with your own conscience. The author doesn’t
take any responsibility if you get other results and lead to another conclusion.

For comparison, we take a scenario of joining four tables. We join tables using new Open SQL, CDS,
CTE and AMDP by keeping the same query across different approaches.

You can find the code on GitHub and clone for yourself to test it.

You may also like to check Best Practices in Code Push Down with S4 HANA.

To compare runtime for each, I am executing each for 10 times and taking an average of them.To
compare runtime for each, I am executing each for 10 times and taking the average of them.I am not
giving time for CTE because it has a different use case than a simple join. You can anyway go ahead and
execute by yourself to see CTE performance.

All Times in milliseconds!


Open SQL CDS AMDP

1. 264.16 228.28 197.63


2. 178.75 204.22 223.59
3. 210.28 201.12 219.49
4. 203.02 184.15 223.47
5. 207.51 170.6 221.25
6. 182.65 207.63 207.4
7. 194.28 170.00 209.98
8. 195.05 181.01 238.32
9. 215.18 170.15 232.45
10. 184.97 161.35 208.81

—————————————————

Avg: 203.58 187.85 218.23

Conclusion: Open SQL, CDS, and AMDP are not competitors for each other and they have different use-
cases.
In this particular case of joining 4 tables, CDS is clear winner followed by open SQL and AMDP.

Question #11: What are the best practices which developers should keep in mind while using ABAP
Core Data Services (CDS)?

Answer:

SAP ABAP HANA Core Data Services(CDS) are foundation of new ABAP. It uses code push down
technique and data virtualization for data fetching from much faster HANA database.

Some of best practices are as below:

1. Use latest innovations in CDS after ABAP 7.50. They help to reduce ABAP code logic and conditions
on application layer. CDS executes at Database layer hence makes the application faster.
2. Publishes oData services on the fly
3. CDS can be consumed directly by Fiori reports effortlessly. This feature should be used as and when
required instead of providing conventional reporting solutions to customers(e.g. ALV).
4. Analytics out of box

Question #12: How ABAP CDS controls Access with DCL(Data Control Language)?

Answer:

SAP ABAP HANA Core Data Services(CDS) uses syntax Define Role for access condition. This role
management arrangement can further utilizes PFCG based role access. Example:

@MappingRole: True
define role Test_CDS_Role {
grant select on Test_CDS_pfcg
where (bukrs) =
aspect pfcg_auth (p_bukrs, bukrs, actvt='03'
and land1 = 'DE'; }

And CDS view is as follows:


@AbapCatalog.sqlViewName: 'Test_CDS_01'
@AccessControl.authorizationCheck: #CHECK
define view Test_CDS_pfcg
as select from t001{ key bukrs,
land1 };
.

Question #13: Which annotation in SAP ABAP CDS View is used to define underlying ABAP Data
Dictionary(DDIC) structure?

Answer:

ABAP Core Data Services uses syntax @AbapCatalog.sqlViewName to define underlying ABAP Data
Dictionary(DDIC) structure. Example:

@AbapCatalog.sqlViewName: 'DEMO_VIEW_ANNOT'
@AccessControl.authorizationCheck: #NOT_REQUIRED
@ClientDependent: false

define view...

In above example, view DEMO_VIEW_ANNOT can be checked in ABAP dictionary Transaction SE11
however it can’t be edited there. To edit a CDS view, developer needs to use ADT(ABAP Development
Tools for Eclipse). Detailed tutorial on how to install & use ADT is HERE.

Another example:

@AbapCatalog.sqlViewName: 'Test_CDS_01'
@AccessControl.authorizationCheck: #CHECK
@EndUserText.label: 'Demo View with Annotations'

define view Test_CDS_pfcg


as select from t001{ key bukrs,
land1 };
@EndUserText.label is used to define short text of underlying ABAP Data Dictionary(DDIC) structure.

.
Question #14: Which between ABAP CDS entity and CDS view should be used to query CDS in
ABAP program?

@AbapCatalog.sqlViewName: 'TEST_CDS_01'
@AccessControl.authorizationCheck: #CHECK
@EndUserText.label: 'Demo View with Annotations'

define view TEST_CDS_PFCG


as select from t001{ key bukrs,
land1 };

e.g. in above code, TEST_CDS_PFCG should be used for querying or TEST_CDS_01?

Answer:

If ABAP Core Data Services(CDS) needs to be consumed in SELECT statement, always CDS Entity(here
TEST_CDS_PFCG) should be used.

Question #15: ABAP CDS syntax rules:

1. Maximum length of CDS entity name?

2. Can Slash (/) be used to name an ABAP CDS entity?

3. Is “.15” a valid literal in CDS definition?

4. How to make comments in CDS code?

5. Can you write “Select” or “selecT” to SELECT a data in CDS definition?

Answer:

1. 30 Characters

2. Yes, Slash can be used to start name of CDS also

3. No, .15 is not a valid literal. Alternatively 0.15 can be used

4. There are 3 ways to make comment in CDS code:

 Two slashes //
 Two hyphens —
 /* ……….. */
5. “Select” is correct however “selecT” is a syntax error

Question #16: What is Cyclical Dependency in ABAP CDS?

Answer:

There are primarily two types of dependencies in ABAP CDS viz. Technical and Semantical. A CDS can
be created by calling/joining/associating another CDS and this results in chain of dependencies. However,
when dependencies point to same CDS where it started, results in a Cyclical Dependency. e.g.

CDS View 2:
@AbapCatalog.sqlViewName: 'VIEW1'
define view TEST_VIEW1 as
select from
TEST_VIEW2
{ ...some Selection... }

CDS View 2:
@AbapCatalog.sqlViewName: 'VIEW2'
define view TEST_VIEW2 as
select from
TEST_VIEW1
{ ...some Selection... }

Cyclical dependencies can cause syntax error in CDS code. Normally they are not reported until CDS
view is activated.

Question #17: How to create oData service from a CDS?

Answer:

A special annotation oData.Publish is used to create oData service from within CDS view and that is also
out of box. e.g.

@AbapCatalog.sqlViewName: 'VIEW1'
oData.Publish: True
define view TEST_VIEW1 as
select from
TEST_VIEW2
{ ...some Selection... }

Once CDS is activated, oData service is published which can be further registered in Transaction
/IWFND/MAINT_SERVICE.

Question #18: How to debug CDS view?

Answer:

It is not possible to debug CDS view. If a CDS is using Table function, then of course underlying AMDP
can be debugged.

CDS view is a by design is Database artifact which can be created, modified and accessed using ADT
with Eclipse. CDS practically achieves Code Push Down for AS ABAP.

Question #19: How to find CDS views?

Answer:

There are many ways to find CDS views:

1. With ADT: Type Ctrl(or CMD) + Shift + A >> Use search string with wildcard “*” >> In the end
write “type: ddls”
2. In Transaction SE16: Open Table TADIR >> OBJECT = DDLS >> OBJ_NAME = <CDS name you
are looking for with “*”>
3. In Transaction SE80: Take dropdown for “Development Object” >> Type CDS name with wildcard
“*” >> Suggestions will automatically come for existing CDS names

Question #20: What happens to underlying SE11 view(defined with @AbapCatalog.sqlViewName)


corresponding to CDS when a CDS view is extended?

Answer:
SE11 SQL view gets new fields under “APPEND” corresponding to new fields in CDS extension. Size
and name of new fields are in accordance with their definition in extended CDS.

How to expose CDS View as an OData


service?
By using the annotation @OData.publish : true
READ MORE

ABAP ON HANA CDS INTERVIEW QNA TECHNICAL Q&A

Explain the concept of Metadata Extensions


Metadata Extension is useful in segregating the UI/Consumption related annotations from the Actual
CDS.
It is very handy for enhancing the UI without impacting the CDS. It establishes a loose coupling between
Data Model and UI annotations.
@Metadata.allowExtension: true
READ MORE

ABAP ON HANA CDS INTERVIEW QNA TECHNICAL Q&A

Explain the use of Access Control


CDS access control is used to perform authorization checks.
Annotation used is @AccessControl.authorizationCheck
READ MORE

ABAP ON HANA CDS INTERVIEW QNA TECHNICAL Q&A

Explain the limitations of ABAP CDS.


If logic is more complex then CDS cannot help in achieving code pushdown. We will have to use Table
function with CDS.
READ MORE

ABAP ON HANA CDS INTERVIEW QNA TECHNICAL Q&A


Explain the benefits of ABAP CDS Views
over ABAP Views
ABAP CDS is reusable.
CDS helps in achieving code pushdown.
Act as a single model for Fiori apps.
Can help us to write SQL script inside ABAP using Table function.
READ MORE

ABAP ON HANA CDS INTERVIEW QNA TECHNICAL Q&A

What are the artifacts generated during CDS


View creation? Also explain the concept of
cardinality and path expressions.
CDS View activation generates 2 objects:
CDS View Entity(consumed everywhere) & SQL view at DDIC level.
Cardinality is used to define the relationship among tables. It can be such as ZERO TO ONE, ONE to
ONE,ONE To MANY, MANY to ZERO represented as [0..1],[1..1], [1..*], [*..0]
Path expression is like a where condition which is used inside the CDS select to filter the data.
READ MORE

ABAP ON HANA CDS INTERVIEW QNA TECHNICAL Q&A

How many types of CDS Views are there?


ABAP CDS & HANA CDS.

Further ABAP CDS has categories:

Interface Views,
Composite Views &
Consumption Views.

Now we have further types under these:

CDS with Parameter


CDS with join
CDS with association
Extend view etc.
READ MORE

ABAP ON HANA CDS INTERVIEW QNA TECHNICAL Q&A

How to perform unit and currency conversion


in ABAP CDS?
We have inbuilt functions for this unit_conversion & currency_conversion

You might also like