ABAP for Cloud Development, ©Copyright 2024 SAP SE. All rights reserved.
ABAP - Keyword Documentation → ABAP - RAP Business Objects → RAP - Behavior Definitions → RAP - BDL for Behavior Definitions → RAP - Managed and Unmanaged Behavior Definitions → RAP - EntityBehaviorDefinition → RAP - EntityBehaviorBody → RAP - RAP BO Operations →RAP - draft action
Syntax
[internal] draft action
{[([
authorization:none][,
features: instance])]
[Edit [with additional implementation];]}
| [Activate [optimized] [with additional implementation];]
| [Discard [with additional implementation];]
| [Resume [with additional implementation];]
| [draft determine action Prepare [
extensible]
{
determination [(always)] DetName;
validation [(always)] ValName;
...
}]
| [AdditionalSave;]
1. ... draft action Edit;
2. ... draft action Activate [optimized];
3. ... draft action Discard;
4. ... draft action Resume;
5. ... draft determine action Prepare;
6. ... draft action AdditionalSave;
1. ... with additional implementation
Description
Draft actions are available for draft-enabled RAP BOs only. They allow data to be manipulated on the RAP draft table.
Draft actions must be specified for lock master entities that are defined using the keyword lock master only, as they refer to the whole lockable subtree of a business object.
Draft actions are provided by the RAP framework in all scenarios. An implementation in the ABAP behavior pool is not required. The draft life cycle is determined by the RAP draft-runtime as soon as the business object is draft-enabled. The application developer does not need to implement the creation, update, or saving of draft instances. However, the optional addition with additional implementation is available for some draft actions. It allows an implementation of the respective draft action in the RAP handler method FOR MODIFY ... ACTION in the ABAP behavior pool.
The following RAP BDL operation additions are possible:
Availability
Hint
In draft-enabled scenarios, the names of the draft actions are reserved for the draft actions. Entities that are not draft-enabled can use the names Edit, Activate, and so on, as names for actions. But when the addition with draft; is used to draft-enable a business object, the names of draft actions are forbidden as names for actions.
Further Information
Development guide for the ABAP RESTful Application Programming Model, topic
Draft Actions.
Executable Example
... draft action Edit
Description
The draft action Edit copies an active instance to the draft database table.
Feature and
authorization control
is available for Edit, which can optionally be defined to restrict the
usage of the action. The optional addition with additional implementation is available.
... draft action Activate [optimized]
Description
The draft action Activate is the inverse action to Edit. It copies the content of the draft database table to the persistent database table and clears the draft database table. It includes all changes that were done on the draft application buffer. Activate includes an implicit execution of the draft determine action Prepare.
It is recommended that you always use the optional addition optimized:
The optional addition with additional implementation is available.
... draft action Discard
Description
The draft action Discard deletes the draft instance from the draft database table. The optional addition with additional implementation is available.
... draft action Resume
Description
The draft action Resume is executed when a user continues to work on a draft instance whose exclusive lock for the active data has already expired. It re-creates the lock for the corresponding entity instance on the active database table. It is executed automatically whenever there is a modification on a draft instance whose exclusive lock has expired.
In case of new draft instances, the same feature and authorization control is executed as defined for the standard operation create. In case of edit-draft instances, the same feature and authorization control is executed as defined for the draft action Edit.
The optional addition with additional implementation is available.
Hint
In case of an edit draft, if a
RAP BO precheck is required, this precheck implementation must be triggered explicitly during the
draft action Resume. For this, the addition with additional implementation is required and the respective
RAP handler method must trigger the precheck method. For further details and an example, see the development guide for the ABAP RESTful Application Programming Model, topic
Implementing Prechecks.
... draft determine action Prepare
Description
The draft determine action Prepare executes the determinations and validations that are assigned to it in the behavior definition. The Prepare enables validating draft data before the transition to active data. Prepare is the draft-equivalent to the determine actions for active instances and the rules described in the topic about determine actions apply to Prepare as well, in particular the following:
... draft action AdditionalSave
Description
The draft action AdditionalSave can be used to define an additional draft save for draft instances. It is intended in particular for draft actions with the addition with additional implementation. For these draft actions, an additional save allows additional functionality to be called during the standard save sequence. An implementation in the RAP handler method FOR MODIFY ... FOR ACTION is required. The name of this method is AdditionalSave by default.
It is recommended that the draft action AdditionalSave is defined as internal, as it is called internally by the RAP framework only. It is not possible to execute this action using MODIFY ENTITIES ... EXECUTE in ABAP EML, not even when using the addition IN LOCAL MODE and not from the current RAP BO's ABAP behavior pool. The draft action AdditionalSave is not exposed in an OData service.
The draft action AdditionalSave can be specified in managed and unmanaged BDEFs. Reuse in a projection BDEF or in an interface BDEF with the keyword use is not possible.
Hint
The draft action AdditionalSave is a
static action, this means, the
BDEF derived type
for the importing parameter of the corresponding RAP handler method has a component %cid.
... with additional implementation
Description
The optional addition with additional implementation is available for
Edit, Activate, Discard, and Resume. If it is specified, an implementation for the respective draft action in the
RAP handler method FOR MODIFY in the local ABAP behavior pool is required.