When To Use ABAP SQL, CDS Views and AMDPs

There are several code pushdown techniques, namely, ABAP SQL, CDS views, and AMDPs. You may wonder which technique is the best.

First, let’s be clear that ABAP SQL, CDS views, and AMDPs are not competitors. All these techniques are available for an ABAP developer to use as needed, and all these techniques can help achieve the shift to the code-to-data paradigm.

All these techniques are for data retrieval from databases. An important question arises when to use a certain technique, under certain circumstances. Let’s discuss several different scenarios best suited for each technique. If the data fetch is for a specific object and will not be used/reused elsewhere, we recommend using ABAP SQL

CDS Views

Core data services (CDS) are used in the next generation of data definitions, capable of defining semantically rich database tables/views (CDS entities) and providing access for database-centric applications. These views are technically extensions of SQL where expressions can be used on fields, domain-specific metadata can be defined, and associations created between related tables. Newly defined CDS entities and their metadata are extensible and optimally integrated into the ABAP Dictionary and the ABAP language.

Thus, when required to fetch data related to an entity from related tables with foreign key relationships, a best practice is to create a CDS view. This CDS view could simply involve joins on the related tables. CDS views involve the least amount of coding and can be reused in multiple objects across developments. In other words, a CDS view is a database artifact that can be consumed across objects/applications.

ABAP-Managed Database Procedures (AMDP)

An AMDP is a piece of code executed in the SAP HANA layer. The data it fetches includes some part of business logic to be performed on the fetched data. Usually, the business logic will be performed on vast amounts of data.

As shown in the figure below, when multiple result sets are needed and are part of the functionality, the fetches on the database table might or might not be related. In other words, independent SQL statements are not often used in other objects.

1877_09_022.png?width=940&name=1877_09_022.png&profile=RESIZE_710x

The powerful features of native SQL, such as currency conversion and CE functions, can be leveraged.

This content was originally posted on the SAP PRESS Blog and has been adapted from a section of the book ABAP Development for SAP HANA by Mohd Mohsin Ahmed and Dipak NaikUsed with permission of SAP PRESS. All rights reserved.

Votes: 0
E-mail me when people leave their comments –

I work for SAP PRESS, the world's leading SAP publisher.

You need to be a member of ERPcommunity.com to add comments!

Join ERPcommunity.com

MEMBERSHIP IS FREE!

Recent SAP Jobs




ERPcommunity.com is a 7LinksWeb.com project. You don't have to be big to be noticed.