Skip to content

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

ABAP BDL - DEFINE BEHAVIOR, field

Other versions: 7.31 | 7.40 | 7.54

Syntax


... field(read only | mandatory) field[, field, ...];

Effect

Some fields of a CDS entity can be specified to which certain access restrictions apply:

  • field(read only) FieldName;
    The field FieldName cannot be modified by the operations create and update.
  • field(mandatory) FieldName;
    The field FieldName must be given a value in create operations. In update operations, it must not be given the null value.


Note

Commas can be used to classify multiple fields, Field1, Field2, Field3, ... in the same way:

field(read only) Field1, Field2, Field3;

field(mandatory) Field4, Field5;


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
{
  field (read only) Travel_ID;
  field (mandatory) Agency_ID, Customer_ID, Begin_Date, End_Date;
  create;
  update;
  delete;
}