« Previous Q:1-10 Index Next »
Questions: 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20
You may also be interested in Core Data Services Basics, ABAP 7.5x Basics, Eclipse for ABAPers and ABAP HANA Interview Questions.
Google Translate @ Sidebar
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:
- 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.
- Publishes oData services on the fly
- 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).
- 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:
- With ADT: Type Ctrl(or CMD) + Shift + A >> Use search string with wildcard “*” >> In the end write “type: ddls”
- In Transaction SE16: Open Table TADIR >> OBJECT = DDLS >> OBJ_NAME = <CDS name you are looking for with “*”>
- 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.