Some Best Practices for ABAP Core Data Services
In case you don’t know about ABAP CDS let me short introduce the basic facts. CDS allows building database views with many features of SQL-92 that are available for HANA and anyDB. You can use it for
- data models for operational analytics
- fast queries – identification of business objects or building packages for parallelization
- fast data access for OData services where joins are only used if necessary
- you can use is to “redefine” DDIC information in SELECTs which can help you to overcome restrictions in many frameworks like BRFplus
- it will be one major cornerstone for building next generation application apps in NW 7.5 and S/4HANA which was/will be explained in this year’s SAP TechEd.
You can read more about it in the following blogs:
This is only a short blog entry but reflects experiences with ABAP CDS in releases NW 7.40 SP8 and 11 we had in the development of two complex CDS models. Those hints may sound easy but if I had know it earlier many things would have been easier.
Get the latest ADT tools
You need ABAP in Eclipse to create and edit DDL Sources. Please don’t work with older versions of ADT tools. Until summer they allowed some dangerous manipulations that will bring you in big trouble.
Learn SQL-92 and apply SQL best practices
CDS is about view building. Improve your SQL skills before starting with CDS. Otherwise you will most likely create severe errors. Without SQL knowledge it is possible that you will get bad runtime results. But if you are a skelled SQL developer you will get amazing results.
With CDS you can build complex data models. But complexity is no value in itself – simplicity rules. So start slowly and explore all features. The complexity will arise soon when you are building view on view which is the usual programming model.
Learn about restrictions
Sometimes restrictions are hidden in the documentation: http://help.sap.com/abapdocu_740/en/abenselect_cds_para_abexa.htm und the ABAP Keyword Documentation. So please read it carefully. By the way: I am don’t like the way SAP communicates the restrictions but this is the topic of another blog entry.
Use the ABAP package concept
CDS models use to get complex and complicated within short time. I recommend to implement CDS views with different purposes (operational reporting, OData..) in different ABAP packages. One reason for it is to control reuse. I made the experience that most ABAP developers don’t understand the concept of reuse and apply it whenever if it’s possible and not when it is necessary.
Study OSS Notes
CDS is a new technology and there are problems like the one here: http://service.sap.com/sap/support/notes/2023690. So I recommend to study the OSS, from time to time, f.e. following note: http://service.sap.com/sap/support/notes/2238561.
In case of activation errors the following notes are helpful:
- 2146253 – Generated SQL views not created in database
- 2081053 – Cannot create CDS views: Missing base objects
- 2023690 – CDS views are inactive
- 2244893 – Check or activation of table returns error message: Proxy view & is not a CDS view
Be careful before changing data models
We made the experience that changing components of transparent tables can lead to activation erros when there are CDS views with parameters defined on top of it. In this case you have to perform all necessary changes manually. Because of those errors we decided to test changes in CDS models in a sandbox first.
Look at transport protocols
As I mentioned before CDS is a new technology and we had some surprises with the transport behavior. So look at the transport protocols.
Visit this years’s SAP TechEd
CDS is a cornerstone of new business applications – so I recommend to visit ABAP lectures like “DEV106 – The ABAP Programming Model in SAP S/4HANA” (see https://scn.sap.com/community/abap/hana/blog/2015/09/08/abap-at-sap-teched-2015 for example).