Skip to Content
Technical Articles
Author's profile photo Joerg Maier

Buffering CDS View Entities

A CDS entity buffer temporarily caches the data retrieved from a CDS view entity into the shared memory of the current AS ABAP instance.

Starting with the following ABAP releases, buffering of CDS view entities is supported:

  • SAP BTP, ABAP Environment 2202
  • ABAP platform cloud 2202

This new object type (R3TR/DTEB) marks the last step towards feature completeness comparing the new CDS view entities with CDS DDIC-based views.

Please refer to the related blog posts for further information on CDS view entities and migrating from CDS DDIC-based views.

Additionally, please get informed what objects are typical candidates for buffering and check the content of ABAP table buffering.

What’s different?

The following table contrasts buffering of CDS DDIC-based views and new CDS view entities:

Attribute CDS DDIC-based view CDS view entity
Buffered Object CDS-managed DDIC view CDS view entity
Definition of Buffer Using annotations Real syntax
Change of SAP-delivered objects Requires modification Defines additional buffer object
Generic Buffer: Number of key elements Client column (MANDT) counts Client column (MANDT) does not count

Prepare CDS View Entity for Buffer Definitions

The following annotation makes sure your CDS view entity is prepared for buffer definitions:

@AbapCatalog.entityBuffer.definitionAllowed: true

This annotation is required as a first step to allow subsequent creation of buffer definition objects. The annotation itself does not lead to a buffer, but ensures the following restrictions apply:

  • Views with parameters are not supported
  • Views with unstable calculations are not supported (e.g. utcl_current, tstmp_current_utctimestamp)
  • Session variables (other than client) can not be used
  • Base objects have to be tables
  • Key length > 900 bytes is not supported
  • LOB key fields are not allowed
  • Views without key fields can not be buffered
  • Data aging in base tables is not allowed

Syntax

DEFINE VIEW ENTITY BUFFER ON <entity_name>
    TYPE SINGLE|GENERIC|FULL
    LAYER CORE|LOCALIZATION|INDUSTRY|PARTNER|CUSTOMER
    [NUMBER OF KEY ELEMENTS <number>] // Needed for buffer type "GENERIC"
Attribute Name Description
LAYER Multiple buffers on the same entity can be defined on different layers. Thus, it is allowed to overrule a buffer definition of a previous software layer. E.g. a buffer definition in layer CORE can be disabled by a buffer definition in layer CUSTOMER.
TYPE The buffer definition types are identical to the buffering type specifications in SE11 / technical settings or values of @AbapCatalog.buffering.type. Additionally, type NONE can be specified to disable an existing buffer definition.
NUMBER OF KEY ELEMENTS

The key element specification is required for generic buffering, as set for CDS DDIC-based view buffering with annotation @AbapCatalog.buffering.numberOfKeyFields.

The client column is not taken into account.

Layering%20relevance

Layering relevance

Example

Right click on the CDS view entity and choose “New Entity Buffer”

Specify the Name, Description and Package of the buffer definition

Edit the buffer definition source code

After activating the DTEB object ZDEMO_BUFFER, queries to entity DEMO_CDS_FULL_BUFFERED_VIEW are buffered on the application server.

News with 2022 / 2208

With the following releases, functional scope of DTEB buffer definitions has increased:

  • SAP BTP, ABAP Environment 2208
  • ABAP platform cloud 2208
  • S/4HANA 2022

The restriction “Base objects have to be tables” is not valid anymore. Base objects of type CDS view entity are now supported in addition to tables.

To allow a CDS view entity to function as a base object for buffering, it is required this base CDS view entity specifies annotation @AbapCatalog.entityBuffer.definitionAllowed : true.

Schema%20of%20View%20on%20View%20buffering

Schema of View on View buffering

In case of questions, please feel free to leave a comment.

Assigned Tags

      5 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Aleksandr karpov
      Aleksandr karpov

      Hi Joerg. How often buffer refreshes? Can developer clear buffer manually?

      Author's profile photo Joerg Maier
      Joerg Maier
      Blog Post Author

      Hi Aleksandr,

      The synchronization and reset mechanisms are identical to buffered table and DDIC view data, please refer to https://help.sap.com/doc/abapdocu_latest_index_htm/latest/en-US/index.htm?file=abenbuffer_synchro.htm for further information.

      Kind regards, Joerg

       

      Author's profile photo Aleksandr karpov
      Aleksandr karpov

      Thanks, Joerg.

      Author's profile photo Stephan Heinberg
      Stephan Heinberg

      Will buffered tables that are included in buffered CDS Entities be stored again the shared memory, or will there be a reference to the shared table?

      Thanks, Stephan

      Author's profile photo Joerg Maier
      Joerg Maier
      Blog Post Author

      Hi Stephan

      Data is maintained for each buffered object individually, so if queries on the table and the view occur, data is kept for both objects individually in the buffer.

      This is the same as for buffered SE11 views and buffered DDIC based CDS views.

      Please keep in mind that CDS Views might contain aggregates, where predicates, JOINs, UNIONs.

      An application might need to consider reviewing their data accesses if a) data is to be buffered, b) amount of data is large, and c) tables and views are accessed.

      Kind regards, Joerg