🔥 EARLY BIRD SPECIAL:Save 10% on all SAP Online Courses! (Limited Slots)

What is CDS View in SAP ABAP? Views, Annotations & Functions

E
ERPVITS Team
Author
2026-06-10
8 min read
What is CDS View in SAP ABAP? Views, Annotations & Functions

What Is CDS View in SAP ABAP? A Complete Guide to Views, Annotations, and Functions

Since the introduction of SAP HANA, there have been fundamental changes to SAP ABAP development. These changes is a technology that modern ABAP developers have to know — CDS views in SAP ABAP. Whether an ABAP developer is creating Fiori apps, building analytical reports, developing OData services, or extending S/4HANA, CDS is the layer upon which everything sits.

This complete guide will provide a thorough understanding of what a CDS view in SAP ABAP is. This guide will also explain annotations, built-in functions, and provide step-by-step instructions on creating a view for the first time.


What Is CDS View in SAP ABAP?

CDS stands for Core Data Services. A CDS view in SAP ABAP is an ABAP Dictionary data model which uses SQL in a syntax called ABAP CDS DDL (Data Definition Language). Compared to traditional views in a database, CDS views are not limited to the database layer. Furthermore, CDS views carry metadata of a certain meaning, business logic, and encapsulation of access control and services.

CDS in SAP ABAP made its first appearance in SAP NetWeaver 7.40 SP05. Its enhancement has been remarkable in the environment of SAP HANA. SAP HANA provides services for ABAP developers to push logic for data processing at the lower layers, i.e, the database layer.

A CDS view updates the previous version of the process of:

  • Defining convoluted SELECT statements within ABAP programs.
  • Implementing database views which lack meaning and context.
  • Transferring large amounts of data from the database to the application for processing and summarizing.

Thanks to CDS, all of this logic resides within the data model, is defined once, and is available for use in all situations.


Importance of CDS Views in SAP S/4HANA and HANA

CDS Views in SAP ABAP on HANA were created to take advantage of HANA using its column-store. When aggregations, filters, and joins are defined in a CDS view, HANA executes them as pushdowns, meaning that the processing takes place inside the database engine and not within the ABAP application server.

Key advantages of CDS views for S/4HANA:

  • CDS views form the backbone of the complete SAP S/4HANA data model, all standard Virtual Data Models (VDMs) in S/4HANA are CDS views — the complete data model.
  • CDS views provide OData services for SAP Fiori, these are auto-generated by the inclusion of the @OData.publish annotation in the CDS view.
  • CDS views create the foundation for Analytical Queries, CDS based authorization checks, and SAP BW extractors.
  • CDS views enable side-by-side extensibility in SAP BTP by not modifying the core objects.

Types of CDS Views in SAP ABAP

Knowledge of view types presents a clear picture of the view in the CDS model before delving into the view creation.

CDS View Type Purpose
Basic Interface View Direct mapping to a database table; supports the foundation of the VDM
Composite Interface View Joins multiple basic views; business logic can be added
Consumption View View made to expose to UI/OData; embedded UI annotations
Analytical View Created to support embedded analytics; contains annotation focused on Analytical
Extension View Extends a CDS view without the need to modify the existing view

CDS View in SAP ABAP Tutorial: Your First CDS View

This is a step-by-step practice based CDS view in SAP ABAP tutorial to create a basic CDS view.

Prerequisites

  • SAP NetWeaver 7.40 SP05 (ABAP on HANA preferred).
  • Eclipse IDE with ABAP Development Tools (ADT).
  • A user SAP Package.
  • Developer access to the target system.

Step 1: Open ADT and Create a New CDS View

  • Open Eclipse with ADT.
  • In Project Explorer, select your ABAP project.
  • Right-click your package → New → Other ABAP Repository Object.
  • In the Object Type dialog, search for Core Data Services and select Data Definition.
  • Enter a name (example: ZV_SALES_ORDER_ITEMS) and a description.
  • Select a transport request and Finish.

ADT creates a DDL source editor and opens the view definition in a template.

Step 2: Write the DDL Source

Copy the code in the box below to the source editor:

@AbapCatalog.sqlViewName: 'ZV_SO_ITEMS_SQL'
@AbapCatalog.compiler.compareFilter: true
@AccessControl.authorizationCheck: #CHECK
@EndUserText.label: 'Sales Order Items View'

define view ZV_SALES_ORDER_ITEMS
  as select from vbap as item
  inner join vbak as header
    on item.vbeln = header.vbeln
{
  key item.vbeln       as SalesOrder,
  key item.posnr       as SalesOrderItem,
      item.matnr       as Material,
      item.netwr       as NetValue,
      item.waers       as Currency,
      header.kunnr     as SoldToParty,
      header.audat     as OrderDate
}

Step 3: Activate the CDS View

Press Ctrl + F3, or right-click and select Activate. This process will create the CDS View and the SQL View in the ABAP Dictionary with the name ZV_SO_ITEMS_SQL.

Step 4: Visualize the Data

You can get a quick look at the data returned by your view using the Open With → Data Preview option found in the ADT by skipping the tedious work of creating an ABAP program. You can write a basic ABAP SELECT statement to read the view as well.

SELECT * FROM ZV_SALES_ORDER_ITEMS
  WHERE SoldToParty = '1000'
  INTO TABLE @DATA(lt_items).

Learning how to create a CDS view in SAP ABAP is simple. You can complete the entire process within the ADT. Your view is ready to use within ABAP applications, OData, and Fiori services.


SAP ABAP CDS Annotations

SAP ABAP CDS annotations are the metadata tags that are added to a CDS view or CDS view fields. Annotations are used to define a behavior that is beyond what a SQL statement would incorporate. This can be control for frameworks, UI dynamics, access control, analytics, and services. Annotations are prefixed with a @ and are more of an instruction to the ABAP runtime or to the Fiori framework and analytics, rather than the database.

Annotation Categories and Examples

1. AbapCatalog Annotations

Example to show how to adjust dictionary-level behavior:

@AbapCatalog.sqlViewName: 'ZV_EXAMPLE_SQL'   -- Naming the SQL dictionary view
@AbapCatalog.compiler.compareFilter: true     -- Improve filter pushdown
@AbapCatalog.preserveKey: true                -- Keep key fields from data source

2. AccessControl Annotations

@AccessControl.authorizationCheck: #CHECK         -- Implement DCL access control
@AccessControl.authorizationCheck: #NOT_REQUIRED  -- Do not implement check (use with caution)

3. EndUserText Annotations

Add descriptions visible in Fiori and the SAP UI frameworks:

@EndUserText.label: 'Net Order Value'
@EndUserText.quickInfo: 'Net value of the sales order line item in document currency'

4. OData Annotations

One of the most useful features of CDS in SAP ABAP is the ability to generate an OData service automatically:

@OData.publish: true   -- Auto-publish the view as an OData service

When placed at the consumption view level, this annotation is sufficient to create a complete OData V2 service without any further work.

5. UI Annotations

Fiori Elements sales orders layout can be constructed like this:

@UI.lineItem: [{ position: 10, label: 'Sales Order' }]
@UI.selectionField: [{ position: 10 }]
@UI.headerInfo.typeName: 'Sales Order'
@UI.headerInfo.typeNamePlural: 'Sales Orders'

6. Analytics Annotations

To make a CDS view an analytical query that can be used in SAP Analytics Cloud or Embedded Analytics, you can use the following:

@Analytics.query: true                        -- Marks the CDS view as an analytical query
@Analytics.dataCategory: #FACT                -- Says the view is a fact/measure query
@Aggregation.default: #SUM                    -- Sets the default aggregation for the measure to sum

7. Search Annotations

To enable enterprise search integration, the following is sufficient:

@Search.searchable: true
@Search.defaultSearchElement: true

To turn a CDS view into a full data model, annotations are crucial. In order to successfully build production-grade SAP S/4HANA applications, thorough knowledge of SAP ABAP CDS annotations is required.


CDS Functions in SAP ABAP

CDS functions in SAP ABAP are incredibly useful. When designing a CDS view, these built-in library functions are powerful. You can use them to work with logical frameworks and equations, all within the bounds of the database.

String Functions

  • Concatenation: concat( item.vbeln, item.posnr )
  • Substrings: left, right
  • Length: length
  • Trimming: ltrim
  • Case: upper, lower
  • Replacing: replace
ltrim( item.matnr, '0' )
upper( header.bstnk )
replace( item.matnr, '-', '' )

Arithmetic Functions

  • Round: round
  • Absolute Value: abs
  • Integer Division: div
  • Modulo: mod
round( item.netwr, 2 )
abs( item.kzwi1 )
div( item.kwmeng, 10 )
mod( item.posnr, 5 )

Date Functions

  • Current System Date: $session.system_date
  • Add Days: dats_add_days
  • Days Between Dates: dats_days_between
  • Timestamps: tstmp_to_dats
dats_add_days( header.audat, 30 )
dats_days_between( header.audat, header.vdatu )
tstmp_to_dats( timestamp, abap_system_timezone( $session.client, 'NULL' ), $session.client, 'NULL' )

Type Cast

cast( item.kwmeng as abap.dec(13,3) )

Conditional Expressions

case item.abgru
  when '' then 'Active'
  when 'Z1' then 'Cancelled - Customer'
  else 'Rejected'
end as OrderStatus

Coalesce

coalesce( item.netwr, 0 ) as NetValue

Aggregate Functions

  • Aggregate Functions: sum, count, avg, min, max
sum( item.netwr )   as TotalValue
count( * )          as ItemCount
avg( item.netwr )   as AverageValue
min( item.netwr )   as MinValue
max( item.netwr )   as MaxValue

Aggregate CDS View example:

inner join vbak as header on item.vbeln = header.vbeln
{
  key header.kunnr          as Customer,
      sum( item.netwr )     as TotalOrderValue,
      count( * )            as NumberOfItems,
      header.waers          as Currency
}
group by header.kunnr, header.waers

SAP ABAP on HANA: CDS Views Key Differentiators

Working with CDS views in SAP ABAP on HANA grants the developer capabilities that go beyond standard CDS:

  • Table Functions — A CDS Table Function calls an AMDP (ABAP Managed Database Procedure) and returns a table, allowing complex logic such as recursion or dynamic hierarchies that CDS cannot express with standard SQL.
  • Hierarchy CDS Views — Parent-child or level-based hierarchies are hierarchies that CDS Views can naturally express. These are required for certain organizational or cost center structures.
  • External Views — These are ways for HANA Calculation Views or CDS Analytic Views to be available as CDS entities in ABAP.
-- CDS Table Function skeleton (HANA only)
define table function ZTF_MATERIAL_HIERARCHY
  returns {
    matnr   : abap.char(18);
    matkl   : abap.char(9);
    level   : abap.int4;
  }
  implemented by method zcl_tf_material_hier=>get_data;

Table functions and hierarchy views are not available on non-HANA systems and are a primary reason SAP recommends HANA as the database for all new ABAP development.


CDS Access Control: DCL (Data Control Language)

Combined with the other topics in these guides, the most crucial topic in enterprise development on CDS DCL — the access control layer for CDS Views.

DCL sources create conditions to read data from a CDS view, depending on their authorization objects.

@MappingRole: true
define role ZV_SALES_ORDER_ITEMS_DCL {
  grant select on ZV_SALES_ORDER_ITEMS
    where (SalesOrganization) = aspect pfcg_auth(V_VBAK_VKO, VKORG, ACTVT = '03');
}

When @AccessControl.authorizationCheck: #CHECK is defined in a CDS view, the system checks the assigned DCL role at runtime, providing row-level security and alleviating the need for custom ABAP programming.


Guidelines for CDS Development

These guidelines ensure clean, reusable, and maintainable CDS models in production.

  • Always adhere to the VDM layering pattern. Skip layers or mix UI annotations in base views.
  • Always use meaningful semantic field names (alias) as renaming a field breaks all dependent objects.
  • Always implement @AccessControl.authorizationCheck: #CHECK on views exposing sensitive business data.
  • Avoid implementing complex business logic on basic interface views. They should remain close to the raw table structure.
  • Use associations (should be preferred over joins) for navigation type relationships.
  • Use the SQL Explain feature in ADT. Always check the ADT Data Preview before pushing to production.
  • Consistency should be applied to naming the SQL views. Keep custom views under 16 characters and use ZV_ prefix.

Learning CDS Views with ERPVITS

ERPVITS has designed the SAP ABAP on HANA Training to take you through every step in learning CDS Views, from DDL Syntax and Annotation categories, through to generating OData services, Fiori Elements, and AMDP Table Functions. The training includes:

  • Live online classes with a real SAP S/4HANA system.
  • Activities to create CDS Views for every VDM layer.
  • In-depth training on SAP ABAP CDS Annotations for UI, analytics and OData.
  • Activities to create practice projects that follow real S/4HANA extension scenarios.
  • Interview assistance and preparation.

Every ABAP Fresher targeting a career in the SAP BTP industry, and every ABAP professional looking for a career change, now has the opportunity to learn the skills needed to develop CDS views for Production use.

Explore SAP ABAP on HANA Training at ERPVITS


Frequently Asked Questions

What distinguishes a CDS View from a traditional ABAP Database View?

Traditional ABAP Database Views are SQL constructs, and divest of Metadata, Access Control, and Annotations. Conversely, a CDS View is a full blown Data Model. It includes Semantic Metadata and its Annotations allow for Authority Checks, and OData and UI Publishing. Therefore, a CDS View is reusable.

Can you use CDS Views on a Non-HANA Database?

Basic CDS views can run on any database SAP NetWeaver supports starting from 7.40 SP05. However, when it comes to CDS Table Functions, hierarchy views, and Full pushdown, SAP HANA is the database in question.

Is ABAP Knowledge Required to Learn CDS?

Learning CDS does not require advanced ABAP knowledge, although a basic knowledge of ABAP and SQL will help you get started. Knowledge of SAP data models will help you get meaningful views much quicker (i.e. knowledge of SD/MM data structures).

What Tools Do I Need to Create CDS Views?

The tool of choice for CDS development is the Eclipse IDE with the ABAP Development Tools (ADT) plug-in. The transaction SE11 (ABAP Dictionary) will only show the SQL View that is generated. The source DDL is managed solely by ADT.


From Fiori UI services to embedded analytics, OData APIs, and authority checks, CDS is the unifying layer across the entire SAP S/4HANA stack. Understanding what CDS views are in SAP ABAP, knowing about SAP ABAP CDS annotations and how to use CDS functions in SAP ABAP, and practicing SAP ABAP CDS views on HANA will make you a viable real-world S/4HANA and BTP developer.

Now, you can build your own views, one at a time, one layer at a time, with the help of ERPVITS.

ERPVITS provides SAP training for the specific requirements of the industry. Visit ERPVITS for details on courses.