ABAP for Cloud Development
AS ABAP Release 914, ©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;
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:
internal
: Available for all draft actions.(features:instance)
: Dynamic feature control is available only forEdit
. ForEdit
, it is per default implicitly enabled.authorization:none
: Available only forEdit
.
Availability
- Managed and draft-enabled RAP BOs (mandatory).
- Unmanaged and draft-enabled RAP BOs (mandatory).
- In projection BDEFs that reuse RAP draft handling, the draft actions must be reused using the syntax
use action DraftActionName
. For details on reuse, see topic RAP -use
, Projection and Interface BDEF. - In RAP BO interfaces that reuse RAP draft handling, the draft actions must be reused using the syntax
use action DraftActionName
. For details on reuse, see topic RAP -use
, Projection and Interface BDEF.
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
- The example above is explained in detail in the topic RAP - Draft Actions Edit, Discard, Prepare.
- Another executable example for the draft action
Activate
can be found in the topic RAP - Draft ActionActivate
.
Variant 1
... 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.
Variant 2
... draft action Activate
optimizedDescription
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
:
optimized
speeds up the activation of draft instances considerably by reducing the number of determination and validation executions in a RAP transaction.- As a prerequisite, determinations and validations must be modeled according to the guidelines described in the development guide for the ABAP RESTful Application Programming Model, section Determination and Validation Modelling. For example, it must be ensured that the validations and determinations handle draft and active instances identically.
- Further details are described in the development guide for the ABAP RESTful Application Programming Model in the following topics:
The optional addition with additional implementation
is available.
Variant 3
... 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.
Variant 4
... 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.
Variant 5
... 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:
- Only validations and determinations defined as
on save
can be assigned. - The assignment of determinations and validations must be done explicitly in the BDEF. Only determinations and validations that are defined and implemented for the BO can be used.
- It is also possible to not define any determinations or validations to the draft determine action
Prepare
. - The optional addition (always) can be used.
- Determinations and validations of child entities can be included.
- Available for managed scenarios and for unmanaged and draft-enabled scenarios.
- The optional addition
extensible
allows validations and determinations to be added to the draft determine actionPrepare
in question by means of BDEF extensions. For further details on extensibility enabling, see topic RAP - Extensibility Enabling for Base BOs.
Variant 6
... 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
.
Addition 1
... 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.