CDS - Interview Questions
CDS - Interview Questions
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:
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).
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.
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.
Question #9Compare the performance of New Open SQL, CDS, AMDP and CTE?
Answer:
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.
—————————————————
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.
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'; }
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'
.
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'
Answer:
If ABAP Core Data Services(CDS) needs to be consumed in SELECT statement, always CDS Entity(here
TEST_CDS_PFCG) should be used.
Answer:
1. 30 Characters
Two slashes //
Two hyphens —
/* ……….. */
5. “Select” is correct however “selecT” is a syntax error
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.
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.
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.
Answer:
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
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.
Interface Views,
Composite Views &
Consumption Views.