AMDP & CDS ABAP On HANA Interview Question
AMDP & CDS ABAP On HANA Interview Question
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.
Q) What are the different types of languages associated with the CDS?
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.
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
Ans) Normal View: Defines a CDS view in the ABAP CDS in a CDS source code. A
Two objects are created for a CDS view that is defined using DEFINE VIEW. A name
The name CDS_DB_VIEW of the CDS database view must be specified in quotation
foundation of the CDS view in ABAP Dictionary. The associated SQL view is created
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.
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).
After activating a CDS view, the following objects are created in ABAP Dictionary:
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:
Optional associations association1, association2, ... for the SELECT statement of the
extended CDS 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:
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:
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.
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
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:
2. Creating and implementing ABAP classes that serve as a code exit for
implementing the virtual element contract.
In case of implementing filters for virtual elements, you need to create conditions
for the substitution of filters on virtual elements.