Skip to content

ABAP Keyword Documentation →  ABAP − Reference →  ABAP RESTful Programming Model →  Behavior Definitions →  ABAP BDL 

ABAP BDL - DEFINE BEHAVIOR

Other versions: 7.31 | 7.40 | 7.54

Syntax


define behavior for CDSEntityName [alias AliasName] 
  [implementation in class ClassName unique]
  [late numbering [in place]]
  [etag field|AncestorEntity~Field ( LocalField = MasterField )]
  [lock master|dependent ( LocalField = MasterField )]
  {
    [field(read only | mandatory) field1[, field2, ...];]
    [internal] create;
    [internal] update;
    [internal] delete;
    [internal] [static] action ActionName
        [external LongName]
        [parameter InputParameterEntity|$self]
        [result cardinality OutputParameterEntity|$self];
    [internal] association AssociationName
        [abbreviation AbbreviationName] {[[internal]create;]};
  }

Effect

Similarly to CDS entities, the behavior for an entity can be divided into a part for once-only specifications (implementation, late numbering, etag, and lock), followed by a part of multiple specifications (field, standard operations, actions, and associations) enclosed in {...}.


Example

In the following example, the data from the ABAP flight data reference scenario (or flight data scenario for short) is used. It represents a legacy business logic that can be used to create and edit flight bookings. The CDS view /DMO/I_Travel represents the root node of the business object for managing flight trips. The underlying business model is described in ABAP BDL - Example.

The following example shows the behavior definition for the root entity Travel.

implementation unmanaged;
define behavior for /DMO/I_Travel alias Travel
late numbering
lock master
etag LastChangedAt
{
  field (read only) Travel_ID;
  field (mandatory) Agency_ID, Customer_ID, Begin_Date, End_Date;
  create;
  update;
  delete;
  action set_status_booked result [1] $self;
  association _Booking { create; }
}

Continue

ABAP BDL - DEFINE BEHAVIOR, alias

ABAP BDL - DEFINE BEHAVIOR, in class unique

ABAP BDL - DEFINE BEHAVIOR, late numbering

ABAP BDL - DEFINE BEHAVIOR, etag

ABAP BDL - DEFINE BEHAVIOR, lock

ABAP BDL - DEFINE BEHAVIOR, field

ABAP BDL - DEFINE BEHAVIOR, Standard Operations

ABAP BDL - DEFINE BEHAVIOR, action

ABAP BDL - DEFINE BEHAVIOR, association