The data of an application is distributed across several database tables. Using ABAP CDS views, you can rearrange the table fields according to application-specific needs from the ABAP source code of your implementation.
The structure of such a view is defined by specifying the relevant database tables and the set of table fields to be used in the view.
A CDS view is defined for existing database tables and views, or for other CDS views in ABAP Dictionary, using the ABAP CDS statement DEFINE VIEW. A CDS view serves to define the structure of an SQL view and represents a projection onto one or several Dictionary tables or Dictionary views.
@AbapCatalog.sqlViewName: 'CUSTOMER_VW' DEFINE VIEW cust_book_view_entity AS SELECT FROM scustom JOIN sbook ON scustom.id = sbook.customid { scustom.id, scustom.name, sbook.bookid }
The CDS entity cust_book_view_entity defines a projection onto the database tables scustom and sbook by joining both tables. The generated SQL view (CUSTOMER_VW) comprises the ID, the name, and the booking ID of all customers for which the bookings exist.
When activating a CDS view, the following objects are created in ABAP Dictionary:
Like regular Dictionary projection views, ABAP CDS entities can be used in ABAP Open SQL for data selection. The following method lists the customer's booking data that is stored in the underlying database tables. As demonstrated in the listing below, the CDS entity (in this case: cust_book_view_entity) is used for data selection in the ABAP source code.
CLASS cl_demo_access_cds_entity IMPLEMENTATION. ... METHOD get_data. SELECT id name bookid FROM cust_book_view_entity INTO TABLE @DATA(result_data) WHERE ... . ENDMETHOD. ... ENDCLASS.
The following figure combines the main components of the view-building architecture and also displays the most important activities that are involved in the view-building process. Using a wizard within the Eclipse-based IDE, you first create the DDL source as the relevant development object. In ABAP Development Tools, the text-based DDL editor is used to write source code in which you specify the data definition for a new CDS view. For each CDS view that is defined in the DDL source, you will generate – using the activation process – exactly one SQL view and the corresponding CDS entity in the ABAP Dictionary.
When activating a DDL source, a CDS entity and SQL view form a unity within the DDL source as development object. So, after transporting a DDL source, the name of the CDS entity and SQL view can no more be changed. To rename any part of this unity, you need to delete the corresponding DDL source. Consequently, you recreate it and use the new name for the relevant part.
See also: Editing DDL Source Code
See also: Displaying the Graphical Representation of DDL Source Code