This is a test message to test the length of the message box.
Login
|
ABAP CDS Extension
Created by Software-Heroes

CDS - Extension of Views

4061

This article is about the extension of views to include customer-specific fields or to provide missing information.

Advertising


Article update: Since release 7.57 (S/4 HANA 2022), DEFINE VIEW is marked as obsolete, you should use DEFINE VIEW ENTITY instead. These may differ from the examples in some places. You can find more information about the new views in this article.



In this article, we look at extending Core Data Services and how we can make additional fields available to apps. In doing so, we will roughly describe the two extension methodologies that are currently used.

 

Preperation

In the first step we look at the extension of CDS Views and how we can add additional information. First of all, let's define a view that we want to extend. This is based on the Basic View for discounts:

@AbapCatalog.sqlViewName: 'ZBSCDMODISEXT'
@EndUserText.label: 'CDS Extension'
define view ZBS_C_DmoDiscountExtension
  as select from ZBS_I_DmoDiscount
{
  key PartnerNumber,
  key MaterialNumber,
      DiscountValue,
      _Material.MaterialName,
      _Material.MaterialDescription
}

 

As you can see, it's a simple view, we'll take over the keys and add some additional information to the texts for the material.

 

EXTEND VIEW

In the second step, we now want to expand the "ZBS_C_DmoDiscountExtension" view because we need additional information that is currently missing in the app that is above this view. Let's assume that since it's a standard view, we can't extend the view. For this we create a new Core Data Services, but with the pattern "Extend View" and we adopt the new field:

@AbapCatalog.sqlViewAppendName: 'ZBSEDMODISEXT'
@EndUserText.label: 'Extension for ZBS_C_DmoDiscountExtension'
extend view ZBS_C_DmoDiscountExtension with ZBS_E_DmoDiscountExtension
{
  _Partner.PartnerName
}

 

The annotation "@AbapCatalog.sqlViewAppendName" differs from the previously created views. Here we define an extension of the Core Data Service and add the partner name. In the SE11 this would look like this:

 

The new field is created as an append and the view is thus cleanly expanded. In Eclipse you would now get a corresponding mark on the original view:

 

The corresponding entry also appears in the CDS Navigator of the view and refers to the extension:

 

If we now look at the "Data Preview" for the Core Data Service, the new field is automatically adopted and is available to us. The view has been extended accordingly without having to change the original view:

 

Hint: The extension also has its own naming convention with E for extension, so that the extension view can still be distinguished from the data model.

 

Association

The second extension option is to integrate an extension into the various entities of the data model via association, especially if the database table also requires the new field. In this extension scenario, additional data should be stored in the application, but at the same time the app should display the data in the UI.

In most cases, the extensions are installed and made available as "_Extension". As a separate view, it directly integrates the database table and is implemented in the corresponding views via association:

 

The fields can then be attached to the extension view again with an extend. These views usually have the corresponding annotation "@VDM.viewType: #EXTENSION". This expansion option is mainly used in the SAP standard when working with the key user apps.

 

Conclusion

The extension of CDS views is now also possible without modification and the resources remain cleanly separated in the system. If you need more content in a view, you should think about expanding before copying.


Included topics:
CDSCore Data ServiceExtensionExtend
Comments (0)



And further ...

Are you satisfied with the content of the article? We post new content in the ABAP area every Tuesday and Friday and irregularly in all other areas. Take a look at our tools and apps, we provide them free of charge.


CDS - Typed Literals

Category - ABAP

How can you work with even greater type precision in a Core Data Service when creating an element in the view? To find out, we'll look at typed literals and how they can help you in everyday use.

01/30/2026

RAP - CDS Pattern

Category - ABAP

How does the CDS pattern actually work, and what does CDS-only have to do with it? In this article, we'll look at the architecture and use of the pattern.

11/28/2025

CDS - Types of Data Definitions

Category - ABAP

When you create Core Data Services in the system, numerous types are available. This article will take a look at the different types and their uses.

11/21/2025

CDS - Writable View Entity

Category - ABAP

Can you perform an update to a Core Data Service in ABAP? Let's look at the new CDS view entities.

04/01/2025

CDS - Authority check (Part 2)

Category - ABAP

How do you deal with the issue of access control in Core Data Services in ABAP and how can you analyze errors? Read more in the article.

03/14/2025