Get Example source ABAP code based on a different SAP table
• DEFINE BEHAVIOR FOR ABAP_BDL • ALIAS ABAP_BDL
ABAP_RAP - Entity Behavior Definition
ABAP_SYNTAX define behavior for RootEntity $[alias AliasName$] $[external ExternalName$] ${$[implementation in class ClassName $[unique$]>$]$} entity behavior characteristics> { entity behavior body> }
$[behavior for ChildEntity1$]$[, behavior for ChildEntity2$]$[, ... $]>
What does it do? Defines the behavior for a RAP business object> in the RAP BDL >. A RAP behavior definition > can consist of one or more entity behavior definitions> that start with define behavior for>, each one referring to a different node> of the business object. An entity behavior definition for the RAP BO root entity> RootEntity > must be included, whereas entity behavior definitions for child entities> are optional. If an entity does not have its own entity behavior definition, the entity does not have a transactional character. It is then not modifiable within the ABAP RESTful application programming model>. In a managed RAP BO>, the possible root entities RootEntity > are CDS view entities> or ABAP_CDS_V1_VIEWS > (deprecated). In an unmanaged RAP BO>, the possible root entities RootEntity > are CDS view entities>, CDS custom entities>, or ABAP_CDS_V1_VIEWS > (deprecated). ABAP_NOTE Custom entities serve as data model basis for RAP unmanaged queries>. Syntax additions and components:
An alias name can be specified using the keyword alias>. This name can be clearer than the entity name itself, since it does not need to be uniquely global in ABAP Dictionary >. The alias name is visible in the method syntax of the behavior pool> of the business object and in the derived types>. The length of an alias name AliasName> is restricted to 30 characters.
The optional addition external> can be used to provide an alias name for external usage. This external name is exposed in the OData metadata, but it is not known by ABAP. It can be much longer than the alias name.
An ABAP behavior pool>, referred to using RAP BDL - implementation in class unique> , can be specified for each entity.
entity behavior characteristics> define general properties for each entity.
The entity behavior body> defines, among others, operations> and field characteristics> that define and restrict the access of a RAP BO consumer> to the respective entity.
Latest notes:
If BDEF strict mode> is enabled, no gaps are allowed in the behavior enablement of a composition tree>. For example, if a composition tree consists of entities 1 (root), 2 (child), and 3 (grandchild), the definition of a behavior for entities 1 and 3 but not for entity 2 is not allowed, as that would be a gap.
If BDEF strict mode> is enabled, the underlying CDS entities RootEntity>, ChildEntity1>, ChildEntity2> and so on, must be CDS view entities>. NON_V5_HINTS ABAP_HINT_END
ABAP_EXAMPLE_VX5 The following example shows a managed BDEF based on the CDS root view entity DEMO_RAP_MANAGED_ASSOC_ROOT>>. The CDS composition tree consists of the root entity and one child entity. For both entities, an entity behavior definition is defined. ABAP_NOTE This example does not fully meet the requirements of the RAP BO contract>. It is intentionally kept short and simple and serves demonstration purposes only. See more information on the RAP BO contract in the Development guide for the ABAP RESTful Application Programming Model>. BDEF DEMO_RAP_MANAGED_ASSOC_ROOT ABAP_EXAMPLE_END
ABAP_EXAMPLE_VX5 The following example shows an unmanaged BDEF based on the CDS root view entity DEMO_RAP_UNMANAGED_DRAFT_ROOT >>. The CDS composition tree consists of the root entity and one child entity. For both entities, an entity behavior definition is defined. BDEF DEMO_RAP_UNMANAGED_DRAFT_ROOT The behavior is defined in the BP_DEMO_RAP_UNMANAGED_DRAFT_ROCCIMP>> of the ABAP behavior pool. ABAP_EXAMPLE_END