ABAP RAP Advanced

Multiple Implementation Classes

Separate Implementation per Entity

Approach: Separate Implementation per Entity

  • Each entity can have its own Behavior Implementation Class
  • This class contains all validations, determinations, and actions for the entity
  • Promotes clear separation of responsibilities in the RAP model
  • Simplifies maintenance and scalability as functionality grows

Advantages of This Approach

  • Clear and structured code organization
  • Avoids monolithic and overloaded implementations
  • Better teamwork through clear ownership per entity
  • Easier testing and debugging of individual entities

Implementation in Behavior Definition

define behavior for ZI_Task alias Task
implementation in class zbp_i_task unique
persistent table zbc_tasks
{
    ...
}

define behavior for ZI_Comment alias Comment
implementation in class zbp_i_comment unique
persistent table zbc_comments
{
    ...
}
  • implementation in class always points to an entity-specific class
  • All related logic methods are grouped there

Best Practice

  • Use clear, entity-based class names (e.g., zbp_i_##_task)
  • Implement all behavior methods (validations, determinations, actions) in this class
  • Consistent usage improves understanding and maintainability
  • Optionally group logic further using group for better structure

Importance of Implementation Groups in BDEF

  • Organize validations, determinations, and actions
  • Avoid complex monolithic implementations
  • Enable parallel development and better clarity
  • Groups reference their own classes with clear responsibilities

Example: BDEF with Groups and Implementation Classes

define behavior for ZI_Comment alias Comment
persistent table zbc_comments
draft table zbc_comment_d
lock dependent by _Task
authorization dependent by _Task
{
field ( numbering : managed, readonly ) Uuid;

group MyChecks implementation in class zbp_i_comment unique {
    validation noEmptyText on save { create; }
}

group MyDeterminations implementation in class zbp_i_comment_det unique {
    determination prefillNumber on modify { create; }
}

...
}

Advantages of Grouping via BDEF

  • Clearly defined logic blocks in behavior specification
  • Easier understanding through separation of validation vs. determination
  • Quick changes to individual areas without side effects
  • Scalable development for complex business objects

Best Practice

  • Group behavior logically by function and responsibility
  • Use descriptive group names for better readability
  • Assign unique class names matching the group and entity
  • Keep group definitions lean and focused