ABAP - Keyword Documentation →  ABAP - Rules for ABAP Cloud →  Contract Rules for ABAP Released APIs →  C0 Contract Rules →  C0 Contract Rules for CDS Entities → 
Mail Feedback

Example: C0 Node Extensibility

This topic provides an example for the node extensibility of a C0 released CDS view entity. It shows how to prepare a CDS view entity for node extensibility and how to add an extension node to a released API from the restricted ABAP language version ABAP for Cloud Development.

CDS view entity as C0 released API

The following CDS view entity DEMO_CDS_PRODUCTTP fulfills all requirements for C0 node extensibility. It defines the necessary extensibility annotations, including @AbapCatalog.extensibility.allowNewCompositions: true.

Note: This CDS view entity shows how to create a released API. It meets all the requirements for C0 release. However, it is not released under the C0 contract for extensibility, because it is not intended to be used as an API.

@EndUserText.label: 'Demo for released API, select from v2'
@AccessControl.authorizationCheck: #NOT_REQUIRED

@AbapCatalog.extensibility: {
  extensible: true,
  elementSuffix: 'EMO',
  allowNewDatasources: false,
  dataSources: ['_Extension'],
  quota: {
    maximumFields: 250,
    maximumBytes: 2500
  },
  allowNewCompositions: true
}
define root view entity DEMO_CDS_PRODUCTTP  
as select from DEMO_CDS_PRODUCT as Product

association [0..1] to DEMO_CDS_PRODUCTTP_E as _Extension  
    on $projection.ProductId = _Extension.product_id
  
{

  key ProductId,

      ProductTitle,
//
      @Semantics.amount.currencyCode: 'Currency'
      Amount,
      Currency,
      
      CreatedBy,
      CreatedOn,
      CreatedAt,
      LastChangedBy,
      LastChangedOn,
      LastChangedAt

}

CDS view entity extension to a C0 released API

The following CDS view entity extension DEMO_C0_NODE_EXT extends the view entity displayed above. It adds a to-child association to an extension node.

Note: The prefix ii is representative. It is meant as reminder to use the correct namespace prefix. In customer systems, the namespace prefix yy or zz must be used.

extend view entity DEMO_CDS_PRODUCTTP with  
composition [1..*] of DEMO_C0_EXTENSION_NODE as ii_comp_emo
{
  ii_comp_emo
}

Extension node

The following CDS view entity is added to the data model as extension node:

@AbapCatalog.viewEnhancementCategory: [#NONE]
@AccessControl.authorizationCheck: #NOT_REQUIRED
@EndUserText.label: 'CDS view entity, C0 extension node'
@Metadata.ignorePropagatedAnnotations: true

define view entity DEMO_C0_EXTENSION_NODE  
as select from demo_tab_ext

association to parent DEMO_CDS_PRODUCTTP as _parent
  on $projection.ProductId = _parent.ProductId  
{
key ingredient_id          as IngredientId,
      product_id             as ProductId,
      ingredient_title       as IngredientTitle,
      ingredient_description as IngredientDescription,
      _parent
}