Create Your First CDS View Entity in ABAP Cloud

45 min read

Why Every RAP Application Starts with a CDS View Entity

If you are developing applications in SAP S/4HANA Public Cloud or using the RESTful Application Programming Model (RAP), the very first artifact you will create is usually a CDS View Entity.

CDS View Entities are much more than database views. They represent reusable business entities that can be consumed by RAP Business Objects, Fiori applications, OData Services, Embedded Analytics, APIs, and many other SAP technologies.

Throughout this learning series, we will build a production-style CDS View Entity and gradually enhance it with built-in data types, CAST, CASE expressions, string functions, numeric functions, associations, aggregations, conversion functions, and other advanced features.

Instead of creating unrelated examples for every lesson, we will continuously improve the same CDS View Entity so that you understand how real SAP applications evolve over time.

Create Your First CDS View Entity
Every modern RAP application begins with a CDS View Entity that represents a reusable business entity.
Click image to enlarge

What You Will Learn

By the end of this lesson you will be able to:

  • Create a CDS View Entity using Eclipse ADT.
  • Understand why SAP introduced DEFINE VIEW ENTITY.
  • Select the correct released Interface View.
  • Understand every keyword in a CDS View Entity.
  • Activate the CDS successfully.
  • Preview data directly from ADT.
  • Follow SAP Clean Core development principles.

What Is a CDS View Entity?

A CDS View Entity is SAP's strategic data modeling artifact for ABAP Cloud and SAP S/4HANA development.

Unlike a traditional SQL View, a CDS View Entity combines business semantics, relationships, calculations, metadata, annotations, and security within a single reusable repository object.

Once created, the same CDS View Entity can be reused by multiple SAP technologies without duplicating business logic.

Where CDS View Entities Are Used

TechnologyPurpose
RAPBusiness Objects and Transactional Applications
Fiori ElementsUI Generation
OData ServicesREST APIs
Embedded AnalyticsKPIs and Reports
Custom ApplicationsReusable Business Data Model

Why SAP Introduced DEFINE VIEW ENTITY

Earlier versions of ABAP CDS used the DEFINE VIEW syntax, which generated an additional SQL View in the ABAP Dictionary.

SAP later introduced DEFINE VIEW ENTITY, eliminating the need for generated SQL Views and simplifying the CDS repository model.

Today, SAP recommends using DEFINE VIEW ENTITY for all new developments in SAP S/4HANA and ABAP Cloud.

DEFINE VIEW vs DEFINE VIEW ENTITY

FeatureDEFINE VIEWDEFINE VIEW ENTITY
SQL View GeneratedYesNo
Recommended for New DevelopmentNoYes
ABAP CloudLimitedFully Supported
Repository ModelLegacyModern

💡 SAP Best Practice

Always use DEFINE VIEW ENTITY when developing new CDS artifacts in SAP S/4HANA Public Cloud or ABAP Cloud.

Prerequisites

Before creating your first CDS View Entity, make sure you have the following prerequisites in place.

Prerequisites

RequirementDescription
ABAP Development Tools (ADT)Latest Eclipse with ABAP Development Tools installed
Development SystemSAP S/4HANA Public Cloud or ABAP Cloud System
Developer ExtensibilityDeveloper Extensibility must be enabled
Development PackageA package where repository objects can be created
AuthorizationPermission to create repository objects

💡 SAP Best Practice

Throughout this course we will use only released SAP artifacts, ensuring every example follows SAP's Clean Core and ABAP Cloud development guidelines.

Choosing the Right Naming Convention

Consistent naming conventions make RAP applications much easier to understand and maintain. SAP recommends using meaningful prefixes for each CDS artifact.

Recommended Naming Convention

ArtifactPrefixExample
Interface CDSZI_ZI_PRODUCT
Projection CDSZC_ZC_PRODUCT
Root CDSZR_ZR_PRODUCT
Behavior DefinitionZI_ZI_PRODUCT
Behavior ProjectionZC_ZC_PRODUCT
Metadata ExtensionZC_ZC_PRODUCT_MDE

Throughout this learning series we will use ZI_PRODUCT as our primary CDS View Entity and extend it in future lessons.

Choosing the Correct Data Source

One of the biggest changes in ABAP Cloud is that developers should no longer access SAP database tables directly.

Instead, SAP exposes released business objects through Interface CDS Views, identified by the prefix I_*.

Common Released Interface Views

Released ViewBusiness Object
I_ProductProduct Master
I_BusinessPartnerBusiness Partner
I_CustomerCustomer
I_SupplierSupplier
I_SalesDocumentSales Order Header
I_SalesDocumentItemSales Order Item
I_PurchaseOrderAPI01Purchase Order

Architect Perspective

Architect Insight

Modern SAP development is business-object centric rather than table-centric.

Instead of asking which table stores the data, ask which released business entity provides it. This mindset is fundamental to ABAP Cloud, RAP, and SAP's Clean Core strategy.

Why We Are Using I_Product

In this lesson we will build our CDS View Entity using the released Interface View I_Product.

This object exposes Product Master data and is available in SAP S/4HANA Public Cloud for application development.

Real Project Example: Why Not MARA?

In classic ABAP development, product information was usually read directly from the MARA table.

In ABAP Cloud, applications should consume the released business API I_Product instead of directly accessing SAP tables.

This keeps applications upgrade-safe and compliant with SAP's Clean Core principles.

Creating the CDS View Entity

Eclipse ADT provides a wizard that automatically creates a new CDS Data Definition object.

Follow these steps:

  1. Open your development package.
  2. Right-click the package.
  3. Select New → Repository Object.
  4. Select Core Data Services → Data Definition.
  5. Enter the object name ZI_PRODUCT.
  6. Enter a meaningful description.
  7. Select the transport request.
  8. Finish the wizard.

ADT creates a new CDS Data Definition with a basic template ready for development.

Building Our First CDS View Entity

Replace the generated template with the following CDS definition.

ZI_PRODUCT.ddls.asddls
ABAP CDS
@AccessControl.authorizationCheck: #NOT_REQUIRED
@EndUserText.label: 'Product'

define view entity ZI_PRODUCT
  as select from I_Product
{
  key Product,
      ProductType,
      BaseUnit,
      CreationDate
}

Don't worry if some of these keywords are unfamiliar. In the next section, we'll break down every line of this CDS View Entity and understand exactly what it does.

Understanding Every Line of the CDS View Entity

Although our first CDS View Entity contains only a few lines of code, every statement has a specific purpose. Before creating more advanced CDS artifacts, it's important to understand what each keyword means.

Understanding the CDS Definition

StatementPurpose
@AccessControl.authorizationCheckDefines whether CDS access control (DCL) is evaluated.
@EndUserText.labelProvides a business-friendly description.
define view entityCreates a modern CDS View Entity.
as select fromSpecifies the CDS data source.
keyDefines the business key of the entity.

Understanding the Header Annotations

CDS Header
ABAP CDS
@AccessControl.authorizationCheck: #NOT_REQUIRED
@EndUserText.label: 'Product'

The first two lines are CDS annotations. These annotations provide metadata that SAP tools use during design time and runtime.

Header Annotation Explanation

AnnotationExplanation
@AccessControl.authorizationCheckSpecifies whether DCL authorization checks should be performed.
@EndUserText.labelBusiness description displayed in ADT and SAP applications.

💡 SAP Best Practice

During learning, using #NOT_REQUIRED keeps the focus on CDS development. In productive applications, authorization is normally implemented using DCL.

Understanding DEFINE VIEW ENTITY

CDS Definition
ABAP CDS
define view entity ZI_PRODUCT

Keyword Breakdown

KeywordMeaning
defineCreates a new repository object.
view entityCreates the modern CDS View Entity object.
ZI_PRODUCTTechnical name of the CDS View Entity.

SAP recommends DEFINE VIEW ENTITY for all new developments because it removes the dependency on generated SQL Views and aligns with the ABAP Cloud programming model.

Understanding the Data Source

Selecting the Source
ABAP CDS
as select from I_Product

Every CDS View Entity requires one or more data sources.

In this example, our source is the released SAP Interface View I_Product.

Why We Use Released Interface Views

Direct Table AccessReleased Interface View
Dependent on SAP internal implementationStable released business API
Not recommended in ABAP CloudRecommended by SAP
Upgrade riskUpgrade-safe
Table-centricBusiness-object centric

Understanding KEY

Business Key
ABAP CDS
key Product

The KEY keyword identifies the business key of the CDS View Entity.

For our Product Master, every product is uniquely identified by the field Product.

Later, when we build RAP Business Objects, these key fields become the unique identifiers used for reading, updating, and deleting business instances.

Activating the CDS View Entity

After completing the implementation, save the object and activate it using Ctrl + F3.

If no syntax errors exist, the CDS View Entity becomes immediately available for consumption.

Expected Activation

Activation completed successfully. Object: ZI_PRODUCT Status: Active

Previewing the Data

Once the CDS View Entity is activated, you can verify the result using the built-in Data Preview available in Eclipse ADT.

  1. Right-click the CDS View Entity.
  2. Select Open With → Data Preview.
  3. Execute the preview.

Expected Data Preview

Product ProductType BaseUnit CreationDate -------------------------------------------------------- FG1000 FERT EA 2024-01-05 RM2000 ROH KG 2023-10-18 SF3000 HALB EA 2024-03-21

The actual records displayed depend on the Product Master data available in your SAP system.

Why CDS View Entities Are Preferred Over Open SQL

Both Open SQL and CDS View Entities can retrieve data from SAP HANA, but they serve different purposes.

Open SQL is intended for program-specific data access, whereas CDS View Entities create reusable business models that can be consumed by multiple SAP technologies.

Open SQL vs CDS View Entity

CapabilityOpen SQLCDS View Entity
Reusable Data ModelNoYes
Business SemanticsNoYes
AnnotationsNoYes
AssociationsNoYes
RAP CompatibleIndirectYes
OData ExposureNoYes
Embedded AnalyticsNoYes

💡 SAP Best Practice

SAP Best Practices

  • Always create new CDS artifacts using DEFINE VIEW ENTITY.
  • Consume released Interface Views (I_*) instead of SAP database tables.
  • Use meaningful business-oriented names for CDS View Entities.
  • Keep CDS View Entities reusable rather than application-specific.
  • Activate frequently while developing to catch syntax errors early.

Common Mistakes

  • Using DEFINE VIEW instead of DEFINE VIEW ENTITY for new developments.
  • Reading SAP tables directly instead of released Interface Views.
  • Forgetting to define business key fields using the KEY keyword.
  • Using inconsistent naming conventions.
  • Ignoring activation warnings and syntax errors.

Real Project Example: Real Project Scenario

Imagine your organization is building a Product Management solution.

Instead of writing multiple Open SQL statements across different applications, the development team creates a reusable CDS View Entity named ZI_PRODUCT.

The same CDS View Entity can then be consumed by:

  • RAP Business Objects
  • Fiori Elements Applications
  • OData Services
  • Analytical Reports
  • External APIs

This approach centralizes the business model, eliminates duplicated logic, and simplifies long-term maintenance.

Architect Perspective

Architect Insight

One of the biggest mindset changes in ABAP Cloud development is moving away from table-centric programming.

Modern SAP development is based on business entities rather than physical database tables.

Instead of asking "Which table contains this data?", experienced developers ask"Which released business entity provides this data?"

This approach aligns your applications with SAP's Clean Core strategy and ensures upgrade-safe extensions.

Interview Questions

BeginnerInterview Question

What is a CDS View Entity?

Answer: A CDS View Entity is SAP's strategic data modeling object used to define reusable business entities that can be consumed by RAP, Fiori, OData, analytics, and other SAP technologies.

ExperiencedInterview Question

Why should new developments use DEFINE VIEW ENTITY instead of DEFINE VIEW?

Answer: DEFINE VIEW ENTITY removes the dependency on generated SQL Views, simplifies the repository model, improves activation performance, and is SAP's recommended syntax for ABAP Cloud development.

ArchitectInterview Question

Why are released Interface Views preferred over direct table access?

Answer: Released Interface Views provide stable, upgrade-safe business APIs aligned with SAP's Clean Core strategy. Direct table access couples applications to SAP's internal implementation and is discouraged in ABAP Cloud.

💡 Key Takeaway

A CDS View Entity is the foundation of modern SAP development.

In this lesson, you created your first CDS View Entity using a released SAP Interface View, understood the purpose of each keyword, activated the object, and previewed the resulting data.

This CDS View Entity will continue to evolve throughout this course. In the next lesson, we will explore ABAP CDS Built-in Data Types, which form the basis for expressions, calculations, and advanced topics such as CAST.