CDS Views
No Comments

SAP ABAP Dictionary Views Vs. SAP ABAP CDS Views – What Are the Differences?

Two origami stars.

ABAP dictionary views or Database Views are created in the SE11 in the ABAP dictionary. ABAP CDS views are created in Eclipse – for now. The guess is that sooner or later they can be developed in the Web IDE as well.

Where an ABAP dictionary view and an ABAP CDS views get created is the first obvious difference. But first things first – what are ABAP dictionary views and what are ABAP CDS views.

ABAP Dictionary Views

ABAP dictionary views fetch from the database pre-defined data. The ABAP dictionary views get from the database by SQL Statements the data needed for an application to process the desired result.

For example, an ABAP application wants to output all products. For this, the application needs to fetch from the database the necessary data of a product. And instead of doing this directly by an SQL statement, the application uses an ABAP dictionary view.

The ABAP dictionary view gets the data of a product from the tables of the database by SQL. It connects all for a product necessary tables of the database by Inner Joins and selects from the tables all the necessary fields for a product.

Then the ABAP application does not use an SQL statement directly to get the data of the product from the database but the ABAP dictionary view. The ABAP dictionary view is like an additional layer between the ABAP application and the database.

For example, the name of the ABAP dictionary view is ZPRODUCTS. It contains all tables and fields which are necessary for a product.

In the ABAP code the ABAP dictionary view could be used like this:

SELECT * FROM zproducts 
    ORDER BY product_name 
    INTO TABLE @DATA(result). 

cl_products_output=>display( result ).

An ABAP dictionary view is a view for one or more database tables. It is literally a view. Imagine you are looking through binoculars at a database. You only focus on certain tables or even just one table.

Same goes with ABAP dictionary views: You pick one certain table or bundle certain tables together. Plus, you can also focus only on certain fields from those chosen tables.

For example, a database contains a bunch of tables. Your application aims to return data which resides in three of the tables of the database. And only one field of each table is necessary. Here comes the view: The view connects those three tables and picks only the fields of the tables which are needed.

When you activate an ABAP dictionary view, then a SQL view is created. This SQL view contains the SQL syntax of the defined ABAP dictionary view. For example, if you connect more than one table with an ABAP dictionary view, then the SQL statement of the SQL View does this by an Inner Join.

ABAP CDS Views

ABAP CDS views were introduced in ABAP 7.40 SP05. There are two variants: ABAP CDS views and HANA CDS views. They are both parts of the new programming model of SAP.

The new programming model of SAP pushes the code and therefore, the logic from the application level down to the database level and up to the front-end or client-side. CDS views pushing the logic down to the database and up to the client-side.

Because they take logic from an ABAP application from the application server and execute it instead at the database level, plus, CDS views allow the control of SAP UI5 Smart Controls and Fiori Elements through annotations and OData services which delegate logic to those controls and therefore the client-side.

Before the new programming model of SAP, the concept was to fetch with pre-defined SQL statements a data package from the database and to process it at the application level to the required result. ABAP dictionary views commonly described the pre-defined SQL statements.

The new programming model does transfer the processing of the SQL fetched data from the application level down to the database level. And it does so by CDS views.

The CDS view does not only pre-define the SQL statement but also contain the logic to process the by the SQL statement fetched data. The aim is to do as much logic as possible at the database level by CDS views.

In the case of ABAP CDS views, the views reside still in the application level in the Data Dictionary (SE11). But a CDS view can transfer more logic in compare to an ABAP dictionary view from the application server to the database through SQL. Nevertheless, an ABAP CDS view still pushes the result of the SQL statement back to the application server.

In the old programming model was the principle the less database load, the better. In the new programming model is the principle the more database load, the better. It is about Code-to-Data and not anymore Data-to-CodeCode-to-the-Database and not anymore Data-from-the-Database-to-the-Code.

ABAP Dictionary Views Vs. ABAP CDS Views

First, ABAP dictionary views in compare to ABAP CDS views is not to be confused with ABAP CDS views in comparison to HANA CDS views.

ABAP Dictionary Views

  • reside in the application server
  • support all kinds of databases
  • limited basic SQL functions as INNER JOIN or SELECT

ABAP CDS Views

  • reside in the application server
  • support all kinds of databases
  • basic SQL functions as INNER JOIN, OUTER JOIN, UNION or SELECT
  • calculations, aggregations, grouping
  • nested views

HANA CDS Views

  • reside integrated into the database (HANA XS)
  • support only HANA databases
  • all the other features of ABAP CDS Views
  • explicit features for the HANA database

5 Reasons to Use ABAP CDS Views Instead of ABAP Dictionary Views in an ECC System

There are 5 reasons to use ABAP CDS views instead of ABAP dictionary views in an ECC system:

  1. upward compatibility to S/4
  2. easy generation of full-fledged OData Services
  3. easy use of SAP UI5 Smart Controls and Fiori Elements
  4. implicit authorization checks
  5. performance boost (see below)

Performance Difference Between ABAP Dictionary Views and ABAP CDS Views

Between an ABAP dictionary views in an ABAP stack with a version of at least 7.40 SP05 and CDS views is no performance difference. Such an ABAP stack with or without an ABAP dictionary view and an ABAP CDS view use exactly the same SQL behind the scenes.

That means the performance is the same if you execute the same SQL statement with or without an ABAP dictionary view in an ABAP Stack or through an ABAP CDS view.

But there is a performance difference in so far that ABAP CDS Views are more flexible. One can make more complex selections by ABAP CDS Views and therefore can omit post-processing of data. For example, with the use of an SQL UNION in an ABAP CDS view.

Most Recent Articles

Will SAP UI5 replace the SAP Web UI?

SAP Full Forms

More Similar Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Fill out this field
Fill out this field
Please enter a valid email address.

Menu