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.
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:
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
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"
|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.
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.
In case of questions, please feel free to leave a comment.
Hi Joerg. How often buffer refreshes? Can developer clear buffer manually?
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
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?
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