Since kernel release 7.83, CDS projection views are available in different flavors, specified using the syntax statement PROVIDER CONTRACT. Each flavor has a different feature set and different syntax checks. This blog post describes the available types of CDS projection views and where to find further details.

Types%20of%20CDS%20projection%20views

Types of CDS projection views

CDS projection view: definition and purpose

CDS projection views are the top-most layer of a CDS data model. They expose data of an underlying CDS data model for a dedicated use case. They correspond to consumption views that make up the C-layer in the Virtual Data Model (VDM) that is used within S/4HANA.

Different kinds of CDS projection views are available. Each comes with its own feature set and its own syntax checks, designed for a dedicated purpose. The type of projection view is specified using the syntax statement PROVIDER CONTRACT.

The following types of CDS projection views are currently available:

 
Type Available since
CDS transactional query
  • Kernel release 7.76
  • SAP BTP ABAP Environment 1905
  • ABAP release 7.54
CDS analytical query
  • Kernel release 7.86
  • SAP BTP ABAP Environment 2111
  • Next big on-prem shipment, perhaps ABAP release 7.57
CDS transactional interface
  • Kernel release 7.86
  • SAP BTP ABAP Environment 2111
  • Next big on-prem shipment, perhaps ABAP release 7.57
No contract
  • Kernel release 7.76
  • Deprecated since kernel release 7.83 | SAP BTP ABAP Environment 2102 | ABAP release 7.56 when provider contracts were first introduced

CDS transactional query

CDS transactional queries are intended for modeling the projection layer of a RAP business object in the context of the ABAP RESTful Application Programming Model (RAP). They represent the top-most layer of a CDS data model and have the purpose to prepare data for a particular use case.

Role of a CDS projection view of type transactional query in a RAP business service:

Example

@EndUserText.label: 'CDS projection view, REDEFINED ASSOC'
@AccessControl.authorizationCheck: #NOT_REQUIRED
define root view entity DEMO_CDS_PV_PARENT
  provider contract transactional_query
  as projection on DEMO_CDS_VIEW_PARENT

    redefine association _child
      redirected to composition child DEMO_CDS_PV_CHILD

{
  key Id,
      Int1,
      /* Associations */
      _child.Int1 as field_exposure
      }

Further details

CDS analytical query

CDS analytical queries are designed for modeling analytical queries within a CDS data model. The projected entity must be an analytical cube view and the feature set is restricted to the capabilities of the runtime of the analytical engine. CDS projection views of type analytical query improve on the previous version of CDS analytical queries (DEFINE VIEW).

Example

@AccessControl.authorizationCheck: #NOT_ALLOWED
define transient view entity DEMO_CDS_ANALYTIC_CASE
  provider contract analytical_query
  as projection on DEMO_CDS_CUBE_VIEW
{
  so_key,

  currency_sum,

  //selection-related case expression
  @Semantics.amount.currencyCode: 'currency_sum'
  case when lifecycle_status between 'A' and 'B'
  then amount_sum else null end as QuantityAB,

  //formula-related case expression
  @Aggregation.default: #FORMULA
  case
  when created_on = $session.system_date
  then abap.int8'200'
  else abap.int8'700'
  end                 as formula_demo
}
where created_on = $session.system_date

Further details

CDS transactional interface

CDS transactional interfaces are intended to serve as stable public interface, for example in a RAP extensibility scenario. To represent a released API, transactional interfaces need to be released under a release contract, for example C0 or C1. The feature set is restricted to projection elements from the underlying projected entity. No new associations, virtual elements, or fields can be defined.

Position of a CDS transactional interface in a CDS data model:

Example

@EndUserText.label: 'CDS transactional interface'
@AccessControl.authorizationCheck: #NOT_REQUIRED
define root view entity DEMO_CDS_TRANS_INTERFACE_ROOT
  provider contract transactional_interface
  as projection on DEMO_CDS_PURCH_DOC_M
{
  key PurchaseDocument,
      Description,
      Status,
      Priority,
      /* Associations */
      _PurchaseDocumentItem: 
        redirected to DEMO_CDS_TRANS_INTERFACE_CHILD
}

Further details

No Contract

If no provider contract is specified

  • CDS projection views were first released with kernel release 7.76.
  • The syntax PROVIDER CONTRACT was first introduced with kernel release 7.83.
  • Projection views that were created before release 7.83 have no provider contract specified. These projection views are treated as transactional queries per default. The same statements are available and the same syntax checks are applied as for CDS transactional queries.
  • Since provider contracts are available, it is mandatory to always specify a provider contract.

Further details

 

Questions, comments, or further details required? Use the Comments section below. Discussions are welcome.

Sara Sampaio

Sara Sampaio

Author Since: March 10, 2022

0 0 votes
Article Rating
Subscribe
Notify of
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x