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
Syntax
extension using interface InterfaceBdef ;
ExtensionHeader
foreign entity
EntityBehaviorExtension
ExtensionEntityBehavior
extend own authorization context
define authorization context
...
Description
Extends an existing RAP behavior definition of type managed or unmanaged using a BDEF extension in the RAP BDL. An existing RAP behavior definition can have one or more BDEF extensions. The number of extensions is not limited.
Naming: BDEF extensions themselves and each single extension element should use a separate namespace to avoid naming conflicts with the original BDEF and its elements. BDEF extensions created in non-SAP and non-partner development systems should use the customer namespace prefix Z
or ZZ
.
A BDEF extension can have the following components:
using interface
: It is strongly recommended that a RAP BO is extended via an interface layer. For details, see the topic RAP -using interface
, Extension.ExtensionHeader
: Mandatory component of a BDEF extension. Similar to the RAP behavior definition header but offers fewer options.- The semicolon after the keyword
extension
is either mandatory or not allowed, depending on the components of theExtensionHeader
. See examples. foreign entity
: Defines a RAP BO entity which is not part of the CDS composition tree of the current RAP BO as part of the response structures. A foreign entity can be defined before, after, or between the other components. Only entities that belong to the same software component can be added as RAP foreign entity to a BDEF extension.EntityBehaviorExtension
: Behavior extension of an existing RAP BO entity.ExtensionEntityBehavior
: Defines the behavior for an extension node. Caution:: Node extensibility is currently not supported for unmanaged RAP BOs.extend own authorization context
: If the extended BO defines a full authorization context, this context can be extended. If the extended BO does not define an own authorization context, it must not be added via an extension.define authorization context
: A new authorization context for disable can be defined in a BDEF extension. The syntax is similar to the syntax for RAP BOs with the following difference: The additionfor disable
is not supported. For details, see topic RAP -define authorization context
.
Example
The following source code shows BDEF extension DEMO_RAP_EXTENSION_1
. It extends BDEF DEMO_RAP_EXTENSIBLE_ROOT
. The extension contains the following components:
- BDEF extension header
- Entity behavior extension
- Extension entity behavior
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;
}
}