ABAP Keyword Documentation → ABAP − Reference → ABAP RESTful Programming Model → Behavior Implementations
Global class
Other versions:
7.31 | 7.40 | 7.54
Syntax
CLASS class_name DEFINITION PUBLIC
[ABSTRACT]
[FINAL]
FOR BEHAVIOR OF CDS_entity_behavior.
PUBLIC SECTION.
PROTECTED SECTION.
PRIVATE SECTION.
ENDCLASS.
CLASS class_name IMPLEMENTATION.
ENDCLASS.
Effect
The behavior pool, a special global ABAP class, is used to implement the transactional behavior of a business object. The global class is implicitly defined as abstract and final.
The behavior definition CDS_entity_behavior specifies the behavior of the business object. ABAP Compiler derives both the operations to implement and the structure types and table types used from behavior definitions. The behavior pool depends on the behavior definition: Changes to the behavior definition lead to its regeneration.
Any number of behavior pools can be assigned to a behavior definition (1:n relation) This way, applications can structure their implementations in multiple units.
The behavior pool can have static methods, CLASS-DATA, CONSTANTS and TYPES.
The actual substance of a behavior pool is located in the local classes. Two types of special local classes can be defined:
- one or more handler classes to implement the interaction phase of the business object behavior
- and a saver class to implement the save phase of the business object behavior.
Note
The behavior pool is not instantiated or inherited.
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 root entity Travel represents the business object for managing flight trips. The underlying data model and the behavior of the root entity Travel are described in ABAP BDL - Example.
The following example shows the global class of the behavior implementation of the business object.
PUBLIC
ABSTRACT
FINAL
FOR BEHAVIOR OF travel.
PUBLIC SECTION.
PROTECTED SECTION.
PRIVATE SECTION.
ENDCLASS.
CLASS zcl_travel IMPLEMENTATION.
ENDCLASS.