Ansicht
Dokumentation

ABENBDL_DRAFT_TABLE - BDL DRAFT TABLE

ABENBDL_DRAFT_TABLE - BDL DRAFT TABLE

CPI1466 during Backup   Fill RESBD Structure from EBP Component Structure  
This documentation is copyright by SAP AG.
SAP E-Book

- draft table

...
draft table DraftTableName
...


Effect

This addition is only relevant for draft-enabled RAP BOs and for these, it is mandatory. It specifies the DDIC database table used to store draft data. The draft table is derived from the corresponding CDS entity. Additionally, it contains some technical information the RAP transactional engine needs to handle the draft. The technical information is added automatically with the draft admin include.

Draft table:

define table DraftTable {
  key client        : abap.clnt not null;
    ...
    "%admin"        : include sych_bdl_draft_admin_inc;}

The draft admin include is the predefined DDIC include structure SYCH_BDL_DRAFT_ADMIN_INC.

In a projection business object, the draft table is automatically inherited and does not need to be explicitly defined. For details, see topic CDS BDL - use, projection BDEF.

Development guide for the ABAP RESTful Application Programming Model, topic Draft Database Table.

Notes

  • A draft table is a regular DDIC database table and can be accessed as such. Access with , Native SQL and AMDP is technically possible, but not recommended. It is recommended that a draft table is accessed using the RAP framework only, for example, with EML, so that the draft metadata get updated automatically.
  • The draft database table can be generated automatically via a quick fix in the behavior definition, which is offered as soon as RAP draft handling is enabled for the business object.
  • When using late numbering for a draft-enabled RAP BO, it is mandatory that the draft table has an additional key field DRAFTUUID of data type raw(16).

Example

The following example demonstrates why is not suitable to access draft database tables.

It shows a managed BDEF based on the CDS root view entity DEMO_RAP_MANAGED_DRAFT_1. The BDEF is draft-enabled and it defines the persistent database table DEMO_DBTAB_ROOT and the draft database table DEMO_DBTAB_DRAFT.

The program DEMO_RAP_MANAGED_DRAFT_1 accesses the business object using EML. It contains the same code block twice: first, it clears the draft database table using the statement DELETE FROM. Then, it creates a new draft instance with the key value '3' using the EML statement MODIFY ENTITIES and commits this entity instance to the draft database table.

Code snippet - this code block is repeated twice:

The first time, this entry is written to the draft database table and displayed as screen output. The second time, however, the creation of the new draft instance fails and the draft database table remains empty. The reason is that the draft database table can't be emptied using . It contains metadata which can't be deleted with and therefore, the key is considered to be a duplicate, even though the draft database table was cleared.

IMAGE @@ABDOC_draft_table.png@@632@@256@@

This demonstrates why the draft database table should only be accessed using the RAP framework, in this case, using either the EML statement DELETE or the draft action Discard to clear all entries from the draft database table.

The program DEMO_RAP_MANAGED_DRAFT_2 demonstrates how to correctly clear a draft database table:

  • It creates a new draft instance with the key value '4' and discards it using the draft action Discard.
  • Then, it successfully creates the same instance again.
  • The instance is deleted again using the EML statement DELETE FROM and created once again.

Result: the creation of a new draft instance with the same key value works three times in a row, because Discard and DELETE FROM clear the entries of the draft table as well as the metadata.

IMAGE @@ABDOC_DRAFT_TABLE.jpg@@637@@341@@






rdisp/max_wprun_time - Maximum work process run time   SUBST_MERGE_LIST - merge external lists to one complete list with #if... logic for R3up  
This documentation is copyright by SAP AG.

Length: 6636 Date: 20240419 Time: 081536     sap01-206 ( 81 ms )