0% found this document useful (0 votes)
486 views16 pages

AMDP & CDS ABAP On HANA Interview Question

The document provides a comprehensive overview of Core Data Services (CDS) in SAP, detailing its definition, types, and the concept of Code Pushdown for efficient data processing. It explains the differences between CDS views and SQL views, the creation of various types of CDS views, and the use of virtual elements for dynamic calculations. Additionally, it covers the implementation of CDS table functions and the associated ABAP methods for enhanced data handling in SAP HANA.

Uploaded by

Sundaran Nair
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)
486 views16 pages

AMDP & CDS ABAP On HANA Interview Question

The document provides a comprehensive overview of Core Data Services (CDS) in SAP, detailing its definition, types, and the concept of Code Pushdown for efficient data processing. It explains the differences between CDS views and SQL views, the creation of various types of CDS views, and the use of virtual elements for dynamic calculations. Additionally, it covers the implementation of CDS table functions and the associated ABAP methods for enhanced data handling in SAP HANA.

Uploaded by

Sundaran Nair
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/ 16

AMDP CDS ODATA Interview Questions Self Study Materials

CDS :
Q) What is CDS? What is top-down approach/Code Push Down/Code To Data

Ans) They are virtual data models that allow direct access to the underlying
tables of the SAP HANA database. hey allow for efficient data processing,
aggregation, and calculation directly on the database layer, enhancing
performance.

Note : A CDS view can be client-dependent, meaning it automatically filters


data based on the logged-in user's client, if at least one of its data sources is
client-dependent; essentially, if the underlying table used in the view is
client-specific, the CDS view will also be client-dependent.

“Code Pushdown” is a paradigm also called “code-to-data”compared to the


classic approach; it is data-centric, meaning you should execute intensive,
expensive computations in the database layer as much as possible to use
the computing power of HANA fully.
Code Pushdown”. Code pushdown means moving data-intense calculations to the
database layer. It means to drive meaningful calculations/feasible calculations that
can be moved to the database layer and not all. For example, finding MIN/MAX,
counting the number of Sales Orders, finding SUM of total Invoices, etc. AMDP also
supports this Code Pushdown

Q) What are the different types of languages associated with the CDS?

Ans) DDL : Data Definition Language: Data Modelling And Retrieval On A


Higher Semantic Level. Extending Native SQL means for higher productivity.

QL: Open SQL query in ABAP

DCL : Data Control Language : It defines Authorizations For CDS views.


Integrate with Classic Authorization Concepts

Q) What is ABAP CDS Entity?


ABAP CDS provides a framework for defining and consuming semantic data models
on the central database of the application server AS ABAP. The specified data
models are based on the data definition language (DDL) and the data control
language (DCL) which are managed by ABAP Dictionary. So, a CDS entity or the
enhancement of a CDS view is defined as source code in the CDS data definition.

To define an ABAP CDS entity, you first need to create a DDL source as the relevant
development object with which you can use the standard functions of the ABAP
Workbench – such as syntax check, activation, or connecting to the Transport
Organizer. A CDS entity is defined in the text-based DDL editor of ABAP Development
Tools in Eclipse/SAP HANA studio.

Q) Example Of Sample CDS views.


Q) Difference between CDS view & SQL View?
Ans) CDS View represents a View that can be modelled/created or modified in
Eclipse/HANA Studio/VS Code only. This cannot be created/Modified in SE11(SAP GUI)
only can be Viewed where as SQL View is auto-generated when a CDS view is
activated. Thus annotation “@AbapCatalog.sqlViewName:” is mandatory.

CDS View shows calculation logic/arithmetic/string operations/ case statements

used, basically, we can have a look at business logic written in it.

whereas SQL view represents only Tables used/Join Conditions/Fields in

Selection/Selection Condition if any.

Associating SQL View for a CDS view is a must except for the Table function.
It is not possible to create CDS views in SAP GUI. The recommended tool for this is

Eclipse IDE with the ABAP Development Tools (ADT) plugin.

Q) What are the different types of CDS View?

Ans) Normal View: Defines a CDS view in the ABAP CDS in a CDS source code. A

CDS is implemented using a query select statement. The annotation

AbapCatalog.sqlViewName must be specified before the view itself is defined

using DEFINE VIEW.

Two objects are created for a CDS view that is defined using DEFINE VIEW. A name

must be specified for each of the two objects:

The name CDS_DB_VIEW of the CDS database view must be specified in quotation

marks after the annotation @AbapCatalog.sqlViewName. This view is the technical

foundation of the CDS view in ABAP Dictionary. The associated SQL view is created

under this name on the database.

 The name CDS_entity of the CDS entity is defined after the keywords DEFINE
VIEW (DEFINE is optional). No quotation marks need to be specified. This
name follows the rules of the CDS database view but can have 30 characters.
The CDS entity represents all properties of the CDS view.
b) Define View with Joins: Defining a join between two data sources of a CDS view
in ABAP CDS. Using join expression. Both inner and outer joins are possible:

A join between two data sources using INNER JOIN or just JOIN selects all entries of
the data sources whose fields meet the ON condition.

A join between two data sources using LEFT OUTER JOIN selects all entries on the
left side. A join between two data sources using RIGHT OUTER JOIN selects all
entries on the right side. Entries that meet the ON condition have the same content
as in the inner join. In entries that do not meet the ON condition, the elements on
the right or left side have the null value that is set to a type-friendly initial value
when the CDS view is used in Open SQL.

In nested join expressions, the order of the evaluation is specified by the


arrangement of the ON conditions. From left to right, the most
adjacent ON conditions are assigned to each JOIN and this expression is
parenthesized implicitly. These implicit parentheses can be made explicit using
actual parentheses, (). This is optional.
c)Define View with Associations: Defining an association of the name _assoc in
a SELECT statement of a CDS view. An association connects the first elementary
data source data_sources pecified as the initial data source (after FROM using
the ON condition cond_exp) to the data source data_source specified as the target
data source (in the definition of the association). The target data source cannot be
built using joins.

An association of a SELECT statement can be accessed - in the same statement at


all places where this is documented - by specifying the association name in path
expressions. When a CDS view is activated with path expressions, the specified
associations are converted to join expressions. The initial data source is shown on
the left side and the target data source is shown on the right side. The ON condition
of the association is added to the ON condition of the join. The type of join depends
on the place where the path expression is used.
Fields of the initial data source, which are specified in the ON condition, must also
be listed in the SELECT list of the current SELECT statement. This ensures that a join
expression can be built from the association (when used in a path expression). In
the ON condition, the field name should be prefixed by $projection and not by the
name of initial data source.

The fields of the target data source must be prefixed in the ON condition by the
name of the association (prefix assoc. separated by a period).

d)Define View With Parameters: Defining a parameterized view


with $parameters.pname: data type/data element in a SELECT statement of a CDS
view. As a developer, you can now parameterize your CDS views. It means you can
define one general views which produce context-specific result sets by using
parameter values passed at execution time. This means that you do no longer need
to create a view for each context!

Defines Input parameters pname1,pname2 in a CDS View in ABAP CDS in a comma


separated list. Each input parameter must be typed with a data type parameter
type.
Note: - The CDS views with parameters are not supported on all SAP certified
databases – At least SAP HANA does support it 🙂 . However, the DDL of the ABAP
CDS allows creating and accessing CDS views with parameters independent of the
database system.

After activating a CDS view, the following objects are created in ABAP Dictionary:

Figure 6: Post activation objects


a). The actual CDS entity (Zcds_View)
b). An SQL view (ZcdsView).

e) Extend View : Extend view is used to extend standard or custom CDS view
without making any changes to the original CDS view. In SQL view of original CDS
view the classical append view is created as .APPEND in ABAP Dictionary. (similar as
append structure is used to extend DDIC tables.)

Extends an existing CDS view using a CDS view extension in CDS source code. The
extension adds the following to the SELECT list of the available view without making
changes:

The elements of the specified extension list select_list_extension as view fields.

Optional associations association1, association2, ... for the SELECT statement of the
extended CDS view.

The annotation AbapCatalog.sqlViewAppendName must be specified before the


view extension itself is defined using EXTEND VIEW.

In, extend view as shown above Zcds_view_ext is extend CDS view which is used for
extension of zcds_view (original cds view) without making any changes to original
view. After, activating the Extend view, spiral like symbol comes in original CDS
view indicating that this view has been extended using other view as shown
in figure below.
As mentioned above after extending any view using extend view it also adds
classical append in SQL view in the ABAP dictionary. The difference between the SQL
view before and after the extension can be seen in figure below.
Comparison of SQL view before and after extending original CDS view.
After activating a CDS view, the following objects are created in ABAP Dictionary:

1). The extend CDS entity (Zcds_View_ext)


2). An SQL view (ZView_ext).

f) Define Table Functions with parameter: A CDS table function is defined in CDS
source code of a CDS data definition in the ABAP Development Tools (ADT) using the
statement DEFINE TABLE_FUNCTION in the ABAP Core Data Services (CDS) DDL. A
CDS table function includes the following:

 The CDS entity


A CDS table function is declared as a CDS entity using DEFINE


TABLE_FUNCTION. As a data type in ABAP Dictionary, the CDS entity
represents a structured type with the elements of the CDS table function as
components and can be used like any CDS entity.

 An AMDP function implementation

CDS table functions are implemented in Native SQL in an AMDP method and the
implementation is managed as an AMDP function by the AMDP framework in the
database system.
The AMDP method is specified after the addition IMPLEMENTED BY in the
definition of the CDS table function using DEFINE TABLE_FUNCTION. It must
be declared as a special AMDP function implementation for precisely one CDS
table function using the addition FOR TABLE FUNCTION.

Example of Table function with parameters.


Figure 11: Definition of AMDP function for Table function with parameters.

Notes:- CDS table functions can only be used in a database system that
supports AMDP.

When a CDS table function is created, the CDS entity must be activated first, before
the associated AMDP function implementation is created.

When a CDS table function is transported, the CDS entity is first transported as part
of the dictionary transport objects and then the AMDP function implementation as
part of the ABAP transport objects. Depending on the size of the transport, there
can be a considerable delay between these two phases where the CDS table
function is not in a usable state.

https://medium.com/@naveenkumarbaskaran/cds-views-part-3-35ca1c8eac9b
Multiple Parameters For CDS views

Q) What is Virtual Element in CDS?

Ans) A "virtual element" in a CDS view within SAP ABAP refers to a field that is not
directly stored in the database but is calculated on-the-fly during runtime using
ABAP logic, essentially creating a temporary field in your application that is derived
from existing data through custom calculations defined in an ABAP class; it allows
you to display additional information in your application without needing to modify
the underlying database structure.

Virtual elements are not stored in the database, meaning they are only
calculated when requested.

Calculated using ABAP: The logic to calculate a virtual element is implemented within an
ABAP class that is referenced in the CDS view definition.
Used in projection views: Virtual elements are typically defined within "consumption" CDS
projection views, which are used to present data to applications.

Annotation usage:
When defining a virtual element in your CDS view, you need to use
annotations like @ObjectModel.virtualElement to specify that the field is
virtual and reference the relevant ABAP class for calculation

The following steps are relevant for providing virtual elements to the CDS data model:

1. Adding the virtual element and corresponding annotations in the relevant


consumption CDS view.

More on this: Adding Annotations for Virtual Elements

2. Creating and implementing ABAP classes that serve as a code exit for
implementing the virtual element contract.

More on this: Implementing ABAP Code Exits for Virtual Elements

In case of implementing filters for virtual elements, you need to create conditions
for the substitution of filters on virtual elements.

3. Creating exception classes for handling application-specific exceptions.

More on this: Creating Application-Specific Exception Classes

You might also like