By now, we all have pretty good clarity that CDS Views, AMDP and Open SQL are not competitors to each other. They all help us to achieve the ‘Code to Data’ Paradigm shift. They are different tools for the same team and they all can co-exist.
Yes, all these are used for fetching data from Database. But we have to use the appropriate tool based on the requirements. Remember, if a needle (read SQL) can do your job then why worry about a sword (read CDS / AMDP). Similarly, if the job can be done ONLY by the needle then you cannot achieve the same result using the sword. After all, “Discretion is the better part of valor“.
Below is some basic guideline to determine the most appropriate “Code to Data” Technique.
CDS Views
i) Only ONE result set can be returned from a CDS View
ii) CDS views amount to least amount of coding with the ability to be reused in multiple objects across developments. In another word, it’s a database artifact that can be consumed across objects/applications
iii) It uses IDA class of SAP GUI hence much faster (kind of paging technique)
Interdependent SQL queries which will be used across applications (programs/object) are the best example for choosing CDS Views
AMD
i) Independent SQL Statement those are not often used in other objects
ii) MULTIPLE result sets are needed
iii) Powerful features of native SQL such as currency conversion and CE functions can be leveraged.
Open SQL
i) If the SQL queries are for the specific object and won’t be needed elsewhere (not reusable)
We cannot create an official guide to determine the Order of Preference for Code Push down. But, practically they can have the below order:
1) Open SQL or CDS views
2) AMDP
What about the order of preference between Open SQL Vs. CDS?
When it comes to reusability, large feature set and domain-specific consumption of data models, then we should go for ABAP CDS. If CDS Views and SQL can achieve the same functionality, then go ahead with the CDS View (which is already there in the system).
If a CDS does not exist and you need this SQL only in one program, do not take the hassle of creating a CDS which would never be used again in another application. Just go ahead and write your Open SQL.
Please note: Both Open SQL and CDS are OPEN to any underlying database i.e. they are Platform Independent. And therefore they are the first choice.
If you still doubt our above justification and explanation, then the below Flow Chart from SAP would help you make the better judgment with confidence.
Before we close, as mentioned in our earlier article New Age Open SQL ABAP 740, at the end of the day, whichever one works best for your project, team and application, use it. The end user would not see any difference in usability and result. It is all about maintenance and knowledge of your technical team members.