Introduction to ABAP CDS Views

by | Aug 1, 2021 | ABAP RAP

Home » SAP » ABAP » ABAP RAP » Introduction to ABAP CDS Views

Preface – This post is part of the SAP ABAP RAP series.

Introduction

SAP ABAP CDS View is used for defining and consuming semantic data models on standard tables or dictionary views. The abbreviation for CDS is Core Data Services. Although SE11 dictionary view and CDS views both create database views at the backend, the ABAP CDS view supersedes the dictionary view in so many ways.

Difference between dictionary view and CDS View

Dictionary ViewCDS View
Can be created from SAP GUI or Eclipse.Can only be created from Eclipse or SAP HANA Studio.
Cannot define Annotations.Annotations are provided to enrich metadata.
Aggregation is not possible.Can provide Aggregation function.
Grouping is not possible.Grouping can be provided.
Join can be used.Join and Union both can be used
 Case Expressions can be used.
 Input parameters can be allowed for filtering data and column calculations
 Operators can be used.

CDS view Types

There are three different VDM view types:

  • Basic view
  • Composite view
  • Consumption view

CDS view Types

Figure 1: CDS view types

1.      Basic View

VDM Basic views are created on the top of DDIC tables or views. It is the only view that interacts directly with the database.

Annotation: @VDM.Viewtype : #BASIC

Properties for Basic View:

  1. Basic views can directly access the database tables and other basic views.
  2. They have an association with other basic views.
  3. Free of redundancies.
  4. They expose all business data.

 

2.      Composite view

The composite view is created on top of the VDM Basic view. It interacts with Basic views for the result set and does not interact with the database directly.

Annotation: @VDM.Viewtype : #COMPOSITE

Properties of Composite View:

  1. They can access other Composite views but not database tables.
  2. They can have an association with other composite views and basic views.
  3. Redundancies might be possible.
  4. They should be reusable.

 

3.      Consumption view

The consumption views are built on top of Interface views. By the name Consumption, we can assume that this view is meant to be consumed by SAP UI5 through OData, Analytical queries, Transactional service models.

Annotation: @VDM.Viewtype : #CONSUMPTION

How to create CDS views in ADT?

To create a CDS view follow the below steps:

  1. Navigate to New ABAP Repository.
    New ABAP Repository
  2. Select Data Definition.
    Select Data Definition
  3. Provide Package, Name, Description of CDS view.
  4. Now from the given options, select Define View.
    Define View
  5. Define data source name, SQL view name, required annotations and other properties.
    Define data source name
  6. Define data selection Query.
    Define data selection Query
  7. Save and activate.

How to view the data from CDS Views?

  1. In the DDL source object, navigate to your CDS view.
  2. Right-click and select OPEN DATA PREVIEW. Also, you can open the CDS view and press F8 to view the data.
  3. The output will show you the retrieved data from CDS View.

Author

0 Comments

Submit a Comment

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Author