Technology Blogs by SAP
Learn how to extend and personalize SAP applications. Follow the SAP technology blog for insights into SAP BTP, ABAP, SAP Analytics Cloud, SAP HANA, and more.
cancel
Showing results for 
Search instead for 
Did you mean: 
AndreaUS
Product and Topic Expert
Product and Topic Expert

RAP Extensibility has been released with ABAP release 7.57 (OP). SAP-delivered RAP BOs can be extended by customers. Customers can add extension fields (field extensibility), behavior (behavior extensibility) and extension nodes (node extensibility) to RAP BOs by means of developer extensibility.

This blog post is about C0 developer extensibility for CDS behavior definitions (BDEFs). It explains how to enable a BDEF for C0 developer extensibility and how to extend a C0-released BDEF.

I have already published blog posts about C0 Developer Extensibility for ABAP Dictionary Objects | SAP Blogs and C0 Developer Extensibility for CDS Data Models | SAP Blogs.

Contents of the current blog post:

  1. Developer extensibility, RAP extensibility, C0 release contract
  2. How to prepare a BDEF for C0 release
  3. How to extend a C0-released BDEF
  4. Release information
  5. Further information

Developer extensibility, RAP extensibility, C0 release contract

Developer extensibility is a new extensibility approach that allows ABAP developers to create upgrade-stable custom ABAP code in cloud and on-premise environments. It delivers flexibility beyond key user extensibility and can be done directly on the software stack using the ABAP Development Tools (ADT) via local released APIs.
RAP extensibility is one use case of developer extensibility. It allows extending a RAP business object - either by adding extension fields, extension behavior, or extension nodes.
RAP extensibility relies on the C0 release contract (extend). Development objects, such as DDIC objects, CDS views, or BDEFs, that are released under the C0 contract guarantee stability at dedicated extension points. Only C0 released APIs can be extended from ABAP for Cloud Development.

How to design a C0-released BDEF

The most important prerequisite for C0 release is that the BDEF in question has been enabled for extensibility. That means it must define stable extensibility anchors. This is done by adding the syntax addition extensible at different positions in the CDS behavior definition. All possible extensibility anchors are highlighted in green in the following image:

  • Most importantly, extensible must be added in the BDEF header. Afterwards, extensible must be added in at least one entity behavior definition after define behavior for.
  • Type mappings, determine actions, and the draft determine action Prepare can optionally be declared as extensible. Extensions to these components are only allowed after explicit extensibility enabling.

If your BDEF is extensibility-enabled in this way, the most important part is done. There are some other rules that are checked during a C0 release, such as the following:

  • Each RAP BO must have at least one RAP BO interface that is C0 released. If this prerequisite in not met, release is still possible, but a warning occurs.
  • If a RAP BO is draft-enabled, a draft query view should be specified (syntax addition query). If this prerequisite in not met, release is still possible, but a warning occurs.
  • A BDEF and all of its elements must use the same (namespace) prefix, or consistently not use any prefix.

An exhaustive list of C0 prerequisites can be found in the ABAP Keyword Documentation under C0 Contract Rules for CDS Behavior Definitions.

Example

The following CDS behavior definition name is based on the CDS view entity name and it fulfills all requirements for C0 release :

 

managed implementation in class bp_demo_rap_base_det_val unique;
strict(2);
extensible
{ with determinations on modify;
  with determinations on save;
  with validations on save; }

define behavior for DEMO_RAP_BASE_DET_VAL
persistent table DEMO_DBTAB_ROOT
lock master
authorization master ( instance )
extensible
{
  create;
  update;
  delete;
  field(readonly:update) key_field;
}

 

RAP BO interface:

 

interface;
extensible;

define behavior for DEMO_RAP_INT_DET_VAL alias RootInterface
{
  use create;
  use update;
  use delete;
}

 

This example is taken from the ABAP Keyword Documentation and it is part of the package SABAPDEMOS.

How to extend a C0-released BDEF

BDEF extensions are allowed in accordance with the extensibility scope defined in the original BDEF, and they must comply with the naming rules. For example, a BDEF extension and all of its elements must use the same namespace prefix.

Example

The following BDEF extension DEMO_RAP_EXT_DET_VAL extends the RAP BO displayed above.

 

extension using interface DEMO_RAP_INT_DET_VAL
 implementation in class bp_demo_rap_ext_det_val unique;
extend behavior for RootInterface
{
  determination setStatus on save { create; }
}

 

  • The extension uses the interface DEMO_RAP_INT_DET_VAL. Extensions are added simultaneously to the interface and to the base BO.
  • The determination setStatus is added to the root node.

Release information

C0 developer extensibility for BDEFs has been available since ABAP release 7.57 (OP), ABAP release 7.89 (quarterly release).

Further information

ABAP Keyword Documentation

Development Guide for the ABAP RESTful Application Programming Model, section Extend.
Questions are welcome.

2 Comments