CDS View Entity

15 min read

What is a CDS View Entity?

A CDS View Entity is the foundation of every RAP Business Object. It defines the business data model that is later enhanced through Behavior Definitions and exposed through OData services.

CDS View Entities are SAP's recommended approach for data modeling in ABAP Cloud and SAP S/4HANA Public Cloud. They replace classical CDS Views and provide a cleaner and more efficient development model.

SAP Recommendation

SAP recommends using CDS View Entities instead of classic CDS Views for all new developments.

Why CDS View Entities?

Before CDS View Entities, developers used classic CDS Views that required SQL View Names and additional metadata objects.

CDS View Entities simplify development, improve activation performance and align better with SAP's Clean Core strategy.

Classic CDS View vs CDS View Entity

Classic CDS ViewCDS View Entity
Requires SQL View NameNo SQL View Name Required
Older TechnologyLatest SAP Standard
More Metadata ObjectsSimplified Architecture
Not Recommended for New DevelopmentSAP Recommended

Creating Your First CDS View Entity

The following example creates a Root CDS View Entity representing employee master data.

ZI_EMPLOYEE
define root view entity ZI_EMPLOYEE
  as select from zemployee
{
  key employee_id      as EmployeeId,
      first_name       as FirstName,
      last_name        as LastName,
      department       as Department,
      email            as Email
}

Understanding the Syntax

Every keyword in the CDS definition serves a specific purpose within RAP architecture.

CDS Syntax Breakdown

KeywordPurpose
defineStarts CDS Definition
rootMain RAP Business Object
view entityCreates CDS View Entity
as select fromSpecifies Data Source
keyPrimary Key Field
aliasBusiness Friendly Field Name
CDS View Entity Architecture
Position of CDS View Entity in RAP Architecture

Role of CDS View Entity in RAP

The CDS View Entity forms the Data Model Layer of RAP. All business logic, service exposure and Fiori applications are built on top of this foundation.

A well-designed CDS model significantly reduces future maintenance and simplifies RAP development.

RAP Architecture Layers

LayerObjectPurpose
Data ModelCDS View EntityBusiness Data Model
BehaviorBehavior DefinitionBusiness Logic
ImplementationBehavior ImplementationCustom Logic
ServiceService DefinitionExpose Business Objects
ExposureService BindingPublish OData Services
UIFiori ElementsGenerate Applications

Best Practice

Use meaningful business keys and design your CDS model while keeping future Associations, Compositions and Behavior Definitions in mind.

Common Mistake

Avoid creating new RAP applications using classic CDS Views with SQL View Names. CDS View Entities should be the default choice.

Public Cloud Considerations

In SAP S/4HANA Public Cloud, CDS View Entities should consume only released APIs and released CDS Views. Direct access to unreleased objects is not permitted.

Following SAP's Clean Core principles ensures future compatibility and smooth upgrades.

Learning Outcome

You can now explain what a CDS View Entity is, create a Root CDS View Entity and understand its role within RAP architecture.

Next Steps

In the next lesson, we will learn Associations and understand how CDS View Entities are linked together to build business object relationships.