ABAP RAP Advanced

Augmentations in RAP

Smarter UIs

Introductory Example

  • A material is created and used
  • Each user wants to view and edit the material text in their own language
  • The data model contains different texts per language
  • The UI should still provide a unified, simple editing interface

Motivation for Augmentations

  • Data model and user experience can differ
  • Example: Only the latest comment should be displayed and editable
  • Behind the scenes, each comment is stored as a new entry

Views for Aggregation

  • ZI_##_Comment_Max: Aggregates the latest timestamp (CreatedAt) per task
  • ZI_##_Comment_Latest: Joins on max timestamp to retrieve the full comment
  • Key in Latest View is TaskKey, as only one entry per task is returned

Extension in the Task Model

  • New association to view ZI_##_Comment_Latest in the Task I-View
  • Projection ZC_##_Task_NoDraft extended with CommentText from the association
  • MDE annotation for visibility and position of the new field

Behavior Definition & Implementation

  • New implementation class ZBP_C_##_Task_NoDraft for the projection
  • Use use update ( augment ) for additional update logic
  • Field CommentText marked as modify for editability
  • Augmented update creates new comments via Create-By-Association
  • Important: Use MODIFY AUGMENTING ENTITIES instead of regular MODIFY
  • Relating tables manage the connection between parent and child

Classic Example Method: augment_update

  • Writes new comment entries when CommentText changes
  • Maintains relation tables to ensure link to tasks
  • Uses Behavior Framework (cl_abap_behavior_handler) and MODIFY AUGMENTING

Benefits of Augmentations

  • Separation of user interface and data persistence
  • Flexible implementation of individual UX requirements
  • Leverages powerful RAP mechanisms for clean extensions without breaking the model

Conclusion

  • Augmentation enables targeted extension of standard operations
  • Ideal for scenarios with differing editing logic
  • Improves maintainability and flexibility in the RAP data model