Skip to Content
Technical Articles

Understanding evolution of CDS and AMDP in most simple way

After reading this blog reader would have a clear idea why SAP recommends CDS views, what is AMDP and what are the benefits of CDS and AMDP over other methods.

As we all know HANA works on Push down techniques means, to make HANA DB do the calculations which was earlier done by application layer in ECC.

Further, Push down technique can be achieved using two approaches:

  1. Bottom-Up approach
  2. Top-Down  approach

1. Bottom-Up approach :

Here In Bottom-Up, we create views (Calculation view, Attribute view, Analytic view) at HANA DB layer with HANA Modelling and these views are later exposed and used in ABAP layer via external views.

External Views :

  1. Read only
  2. Monitored by ABAP dictionary
  3. Can be used in ABAP programs to access data available in the form of Information Views in SAP HANA DB.
  4. More optimized than stored procedures. (discussed below)

Summing up..

  1. Create HANA view in DB layer
  2. Create external view
  3. Use external view in application

So, this is how we use Bottom-Up approach.

Note: Before ABAP 7.4 we were using external view approach.

Question?? Why SAP recommends Top-Down approach

2. Top-Down approach : 

In Top-Down, we create objects using ABAP code that can leverage power of SAP HANA. Here comes CDS and AMDP into picture.

What are we doing in Top-Down?…We are creating models in application layer and it is going to create same in DB layer. Its like, we are using door of application layer to create objects/models in HANA DB.

Drawbacks of Bottom-Up approach :

  1. Need additional license to create views in DB layer (For ABAP and HANA db both)
  2. Dual maintenance
  3. Synchronization of changes (If any change made in DB layer (models) it should be reflected in App. layer)
  4. Transport Management (need separate transports to move across ABAP and HANA db if any changes made in both)
  5. Additional license cost (maintaining both HANA and ABAP layer)

This answers to the question why SAP recommends Top-Down approach.

As we know now Top-Down has benefit over Bottom-Up. So, whatever we were achieving via Bottom-Up we will be achieving same by Top-Down.

In Bottom-Up, we were creating views and later using them in our application layer by exposing them i.e. creating external view. Now, in Top-Down, we achieve this via CDS. We create CDS views in ABAP layer and as we activate or execute the same 2 views created.

  1. ABAP View (at DDIC layer), also called DDL SQL view
  2. HANA View (at HANA DB layer)

Other part was Procedures, we were writing procedures in Bottom-Up approach, directly in HANA DB using native SQL query. Procedures are written if the business requirement is complex and same can’t be achieved via information views.

For exposing Procedures, we can’t use external views so for that we were using stored procedure proxy.

Bottom line : 

  1. For views in Bottom-Up, replacement in Top-Down was CDS
  2. For Procedures in Bottom-up, replacement in Top-Down is AMDP

CDS (Core Data Services) :

  1. Defined in ABAP repository using SQL DDL syntax
  2. use open SQL language
  3. CDS is executed as a single statement, hence we can’t put a debugger inside.

AMDP (ABAP Managed Database Procedures) :

  1. Simple ABAP class method containing DB specific procedure coding.
  2. use native SQL language
  3. Activate AMDP debugger :: Terminate AMDP debugger
  4. The code within the method is pushed to the DB layer and executed within the DB
  5. Should be used only if DB specific functions that do not exist in open SQL needed to be accessed.

CDS VS AMDP :

  1. In AMDP, we can call one function inside the other, it is helpful in returning multiple result set on complex logics. Whereas, CDS is dedicated for single set of logic and return only one result set.
  2. CDS views can be created to read and process data at DB layer. Whereas AMDP can be created to process and modify data at DB layer.
  3. AMDP is used to work with stored procedures, which further go to HANA DB layer and execute that. This functionality can’t be achieved by Open SQL and CDS.

Common features/ Benefits of CDS and AMDP :

  1. We are creating/using DB Procedures in AMDP and views in CDS without having access of HANA DB layer.
  2. AMDP and CDS can be created in eclipse only not in GUI as ADT (ABAP Development Tool) plug-in is needed for this (also in HANA Studio).
  3. CDS and AMDP does not need HANA license, when it is executed first time, it automatically create views and procedures respectively in HANA DB. Next time it will take same from HANA DB buffer.
  4. Transferring data to other systems, CDS will create views and AMDP will create procedures automatically in the new system.

 

 

 

 

3 Comments
You must be Logged on to comment or reply to a post.
  • Hi Ujjwal Singh,

    the need for a Currency Conversion is no argument to use an AMDP as the currency conversion function is also supported within ABAP CDS as a built-in function.

    Is it possible, that your blog is fully based on NetWeaver 7.40?

    If yes, I would add this information – otherwise the reader might be confused, why you don’t describe the interaction between CDS and AMDP, namely CDS Table Functions.

    Best regards,

    Sebastian

    • Hi Sebastian,

      Gratitude for thoroughly reading the blog!!

      As the blog’s title says “Evolution of CDS and AMDP” so, yes, here we are discussing in context of NetWeaver 7.40.

      I am taking note of your suggestion and as time allows will publish a blog on the interaction between CDS and AMDP. Thanks!!

      Update: Currency conversion example is now removed to eliminate confusion.

      Regards,

      Ujjwal Singh