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 - BDEF Extension → RAP - Base BDEF Extension → RAP - extension →
RAP - Extension Entity Behavior Definition
Prerequisite
As a prerequisite, the extended RAP behavior definition must explicitly allow BDEF extensions as described in the topic RAP - Extensibility Enabling for Base BOs.
Description
Defines the behavior for an extension node in a BDEF extension using the statement define behavior for
. As a prerequisite, the node must be added to the RAP data model via RAP data model extensions. The BDEF extension can add behavior for this extension node.
The behavior for the extension node is defined in the same way as for RAP BOs, see EntityBehaviorDefinition
, with the following differences:
- A CDS transactional interface can be specified with the syntax addition
using
(instead ofusing interface
, which is used for RAP BO extensions). - No explicit pointing to a RAP authorization master entity.
- Use
authorization dependent
instead ofauthorization dependent by _Assoc
. - No explicit pointing to a RAP lock master entity.
- Use
lock dependent
instead oflock dependent by _Assoc
. - No explicit pointing to a RAP ETag master entity.
- Use
etag dependent
instead ofetag dependent by _Assoc
. - Note: As a best practice, SAP recommends that an ETag master field is defined for each individual entity. As a consequence, the syntax
etag dependent
should not be used at all. - Declare ancestor associations, so that the path to the authorization master, lock master, and ETag master entities can be derived.
If an ABAP behavior pool is specified, the rules for extension ABPs apply. See the topic RAP - implementation in class unique
, Extension.
Limitation: Node extensibility is currently not supported in unmanaged RAP BOs.
Hints
- A short syntax form is available:
( lock, authorization, etag ) dependent
. Each of the three componentslock
,authorization
, andetag
is optional but at least one of them must be specified within the parentheses. - Currently, only root entities can be defined as authorization master and lock master entity. An extension node can therefore not be specified as authorization master or as lock master entity.
- Currently, RAP business events can only be defined in RAP BO root entities. Since extension nodes are usually below the root node, they cannot define any new RAP business events.
Example
The BDEF extension DEMO_RAP_EXTENSION_1
extends the RAP behavior definition DEMO_RAP_EXTENSIBLE_ROOT
. It behavior-enables an extension node using the syntax define behavior for
. It defines behavior and multiple ancestor associations. Lock, authorization, and ETag master are not specified explicitly, but derived implicitly.
extension using interface demo_rap_ext_using_interface;
foreign entity demo_rap_factory_ACTION;
extend behavior for GrandChildInterface
{
association _Children4Ext { create; with draft; }
}
define behavior for DEMO_RAP_EXTENSIBLE_EXT alias ExtNode
using DEMO_RAP_EXT_USING_INT_EXT
persistent table demo_ggchl_ex_ba
draft table demo_ggrch_ext
etag master Timestamp
( lock, authorization ) dependent
{
update;
delete;
field ( readonly )
KeyField, KeyFieldchild, Keyfieldgrchld;
field ( readonly : update ) Keyfieldggchld;
field ( readonly ) Timestamp;
association _parent { with draft; }
association _Sibling4 { with draft; }
ancestor association _GrandParent2 { with draft; }
ancestor association _GreatGrandParent1 { with draft; }
mapping for demo_ggchl_ex_ba
{
Keyfield = key_field;
Keyfieldchild = key_field_child;
Keyfieldgrchld = key_field_grchld;
Keyfieldggchld = key_field_ggchld;
Datafield = data_field;
Charfield = char_field;
Timestamp = timestamp;
}
}