SAP BDL WITH DRAFT



Get Example source ABAP code based on a different SAP table
  


• WITH DRAFT ABAP_BDL_HEADER

ABAP_RAP - with draft

ABAP_SYNTAX
...
with draft;
...

What does it do?
The addition with draft enables RAP draft handling for a business object . It is added in the behavior definition header as it draft-enables the entire business object. It is not possible to implement draft capabilities for individual entities within a business object.
RAP draft handling is in all scenarios completely managed by the RAP transactional engine. The application developer is not responsible for how draft data is written to the draft database table. However, implementation exits exist that allow scenario-specific capabilities to be implemented.
In projection BOs, draft handling can be reused from the projected BO using the syntax addition use draft . For details, see topic TITLE .

Unmanaged RAP BO
In unmanaged RAP BOs, the following restrictions apply:
Late numbering is not supported.
Associations that use NOT in the binding condition cannot be draft- enabled.
The following RAP BO operations cannot be executed on draft instances :
instance factory actions
direct create operations on child instances (there is no syntax error in BDL, but a short dump occurs at runtime).

Dependencies
The addition with draft enables draft handling. There are several related syntax elements in the behavior definition:
draft table $[ query$]: A RAP draft table is required for storing draft instances. Defined using the keyword draft table DraftTableName. Mandatory for draft-enabled BOs. A draft query view can optionally be specified for a RAP draft table using the addition query.
total etag: The total ETag is a designated field in a draft-enabled business object that indicates changes between the active and the draft version. Total ETag is mandatory for draft-enabled implementations.
draft actions: The draft actions Edit, Activate, Discard, Resume , and Prepare are available for draft business objects. They are implicitly available as soon as a business object is draft-enabled, but can be declared explicitly.
draft-enabled associations: A draft-enabled association retrieves active data if it is followed by an active instance and draft data if is followed by a draft instance . Mandatory for draft-enabled BOs.

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



Latest notes:

If the draft action Edit is enabled implicitly, then it automatically comes with instance feature control and an implementation in the ABAP behavior pool is required. In the following examples, it is enabled explicitly without feature control, so that both implementation scenarios (managed and unmanaged) can be handled by the managed RAP BO provider.
NON_V5_HINTS
ABAP_HINT_END

ABAP_EXAMPLE_VX5 - Managed
The following example shows a managed BDEF based on the CDS root view entity DEMO_RAP_MANAGED_DRAFT_ROOT. It is draft-enabled and the draft is completely handled by the RAP framework; no implementation in the ABAP behavior pool is required.
ABAP_NOTE This example does not fully meet the requirements of the RAP BO contract. It is intentionally kept short and simple and serves demonstration purposes only.
BDEF DEMO_RAP_MANAGED_DRAFT_ROOT
The class CL_DEMO_RAP_MANAGED_DRAFT accesses the business object using EML and performs the following steps:
It creates two new draft instances of the parent entity and two new draft instances of the child entity and displays the content of the draft tables.
Then it activates the draft entities. The content of the draft tables is written to the persistent tables and the draft tables are emptied.
ABAP_EXAMPLE_END

ABAP_EXAMPLE_VX5 - Unmanaged
The following example shows an unmanaged BDEF based on the CDS root view entity DEMO_RAP_UNMANAGED_DRAFT_ROOT . It is draft-enabled and it has all mandatory syntax elements.
The draft is completely handled by the RAP framework; the ABAP behavior pool implements the business logic only for the active entity.
BDEF DEMO_RAP_UNMANAGED_DRAFT_ROOT
The class CL_DEMO_RAP_UNMANAGED_DRAFT accesses the business object using EML and performs the following steps:
It creates two new draft instances of the parent entity and two new draft instances of the child entity and displays the content of the draft tables.
Then it activates the draft entities. The content of the draft tables is written to the persistent tables and the draft tables are emptied.
ABAP_EXAMPLE_END

ABAP_EXAMPLE_ABEXA
RAP BDL - draft actions Edit, Discard, Prepare
RAP BDL - draft action Activate
ABAP_EXAMPLE_END