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 Released CDS View Entity, Design and Consumption

This topic provides an example for the design of a C0 released CDS view entity. It also shows an example for an extension to this 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_E is based on the DDIC database table DEMO_PRODUCT and it fulfills all requirements for C0 release:

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 C0 released API'
@AccessControl.authorizationCheck: #NOT_REQUIRED
@Metadata.ignorePropagatedAnnotations: true

@AbapCatalog.extensibility: {
  extensible: true,
  elementSuffix: 'EMO',
  allowNewDatasources: false,
  dataSources: ['Persistence'],
  quota: {
    maximumFields: 250,
    maximumBytes: 2500
  }
}
define view entity DEMO_CDS_PRODUCTTP_E
  as select from demo_product as Persistence
{
  key product_id
}

CDS view entity extension to a C0 released API

The following CDS view entity extension DEMO_CDS_EXTEND extends the view entity displayed above and it fulfills all requirements for consuming a C0 released API from the restricted ABAP language version ABAP for Cloud Development:

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_E with
association [0..1] to DEMO_CDS_UNIT as _ii_ToUnitEMO  
  on $projection.ii_unit_emo = _ii_ToUnitEMO.UnitOfMeasure
{
  @Semantics.quantity.unitOfMeasure: 'ii_unit_emo'
  Persistence.ii_quantity_emo,
  Persistence.ii_unit_emo,

  _ii_ToUnitEMO
}

The class CL_DEMO_CDS_RELEASED_API_VE provides type information of the enhanced CDS view entity. It also includes the view fields added by the extension.