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 - Non-Standard Operations → RAP - action → RAP - action, Non-Factory →
RAP - repeatable
Syntax
... repeatable ...
Description
Defines a non-factory RAP action or a RAP function as repeatable RAP BO operation. A repeatable RAP BO operation can be executed multiple times on the same RAP BO entity instance within the same ABAP EML or OData request. The BDEF derived type of a repeatable RAP BO operation contains a %cid
component and the RAP response parameters are filled for each execution individually.
Repeatable Actions
- Only non-factory, instance-bound RAP actions can be declared as
repeatable
. Other kinds of RAP actions must not be declared as repeatable for the following reasons: - RAP factory actions are always repeatable and an explicit declaration is not necessary. The BDEF derived type of a RAP factory action contains the
%cid
component and multiple executions are possible. - Static RAP actions are always repeatable and an explicit declaration is not necessary. Static RAP actions are identified by means of a
%cid
component and multiple executions are possible. - Draft actions must not be executed multiple times on the same RAP draft instance within one request. This is not useful and not supported.
- The same rules apply and the same RAP BDL operation additions are available as for non-factory actions, see topic RAP -
action
, Non-Factory. There is only one exception: the syntax additionstatic
is not available for repeatable actions.
Repeatable Functions
- Only instance-bound functions can be declared as
repeatable
. Static RAP functions are always repeatable and they are identified by means of a%cid
component. Therefore, an explicit declaration of the repeatable characteristic is not required and not supported. - The same rules apply and the same RAP BDL operation additions are available as for functions, see topic RAP -
function
. There is only one exception: the syntax additionstatic
is not available for repeatable functions.
Availability
- Managed RAP BO
- Unmanaged RAP BO
- Projection BO: Reuse of repeatable RAP BO operations as well as definition of new repeatable RAP BO operations. For details on reuse, see topic RAP -
use
, Projection and Interface BDEF. For details on action definition, see topic RAP -action
, Projection BDEF. - RAP BO interface: Reuse of repeatable RAP BO operations For details on reuse, see the topic RAP -
use
, Projection and Interface BDEF.
Hint
When executing a RAP repeatable action or function, the BDEF derived type component %cid
must be provided. This can be done using the optional addition AUTO FILL CID
.
Further Information
Example
The following example shows a managed BDEF with multiple actions and functions.
Note: This example is intentionally kept short and simple and focuses on specific RAP aspects. It does not fully meet the requirements of the RAP BO contract.
managed implementation in class bp_demo_rap_repeatable_action unique;
strict ( 2 );
define behavior for DEMO_RAP_REPEATABLE_ACTION alias Root
persistent table demo_cs_rap_tab1
lock master
authorization master ( global )
{
field ( readonly : update ) key_field;
create;
update;
delete;
// dup-key check
action Action;
// no dup-key check
repeatable action RepeatAction;
// no dup-key check (implicitly "repeatable")
factory action FactoryAction [1];
// no dup-key check (implicitly "repeatable")
static action StaticAction;
function Function result [1] $self;
repeatable function RepeatFunction result [1] $self;
}
The BDEF derived type of the non-factory instance-bound action Action
does not have a %cid
component. It looks as follows:
The BDEF derived type of the repeatable action RepeatAction
has a %cid
component. It looks as follows:
The non-factory instance-bound action Action
must not be executed multiple times on the same RAP BO entity instance. The following execution results in a runtime error.
DELETE FROM demo_cs_rap_tab1.
MODIFY ENTITIES OF demo_rap_repeatable_action
ENTITY Root
CREATE FIELDS ( key_field field3 )
WITH VALUE #( ( %cid = 'cid1' key_field = 3 field3 = 77 ) )
EXECUTE Action
FROM VALUE #( ( %cid_ref = 'cid1' ) ( %cid_ref = 'cid1' ) ).
COMMIT ENTITIES.
The repeatable action RepeatAction
can be executed multiple times on the same RAP BO entity instance as follows:
Note: RepeatAction
is not implemented in this example.
DELETE FROM demo_cs_rap_tab1.
MODIFY ENTITIES OF demo_rap_repeatable_action
ENTITY Root
CREATE FIELDS ( key_field field3 )
WITH VALUE #( ( %cid = 'cid1' key_field = 3 field3 = 77 ) )
EXECUTE RepeatAction
FROM VALUE #( ( %cid = 'cid3' %cid_ref = 'cid1' )
( %cid = 'cid4' %cid_ref = 'cid1' ) ).
COMMIT ENTITIES.