ABAP RAP – Advanced Topics

Draft Handling, Projections, Side-Effects and More

Practice-Oriented Deep Dive for ABAP Developers

Agenda

  • SAP Draft Handling
  • RAP Generator with OData V4
  • Projections & Consumptions
  • Augmentations
  • Creating New Objects
  • Number Assignment
  • Side-Effects
  • Multiple Implementation Classes
  • Draft Actions & Additional Save
  • Unmanaged Save & Custom Entities
  • Virtual Elements

SAP Draft Handling

Basics of the Draft Mechanism

  • Temporary storage of user changes
  • Automatic management via RAP framework
  • Differences between “Draft” and “Active Entity”

Advantages

  • Transactions without data loss
  • Parallel editing by multiple users
  • Improved UX with Fiori Elements

RAP Generator in Eclipse

Usage with OData V4

  • Support for draft-enabled scenarios starting with RAP V7.58
  • Generation of BO structure, Behavior Definition, and Data Models
  • Use of templates and wizards in ADT

Hands-On

  • Step-by-step creation of a complete draft stack
  • Activation of draft support via managed implementation

Projections & Consumptions

Goal

  • Abstraction of data models for UI and APIs
  • Definition via Consumption/Projection Views (C-Views)

Approach

  • Projection for previously created Business Object
  • Derivation of the Consumption View for Fiori Elements
  • Integration with @UI annotations

One Object, Multiple Protocols

  • Support for OData V2 and V4 in parallel
  • Adjustment of the Service Definition
  • Handling limitations between versions

Augmentations

Improving the C-Layer

  • Extension of existing C-Views
  • Use of Custom Fields and Logic
  • Adding additional field logic in the consumption layer

Creating New Objects

Challenges with CREATE

  • Validations and default values
  • Mandatory fields
  • Differences between Draft vs. Non-Draft Create

Best Practice

  • Pre-population via initialize method
  • Use of the Local Transaction Buffer

Number Assignment

Variants

  • Early Numbering – key before persistence
  • Late Numbering – key during final save
  • External Numbering – key provided by client/API

Implementation

  • Via Behavior Definition and Determinations

Using Side-Effects

Goal

  • Dynamic UI reactions to events

Typical Scenarios

  • After actions (e.g., status changes)
  • On field changes (e.g., recalculations)
  • After persistence (refresh UI)

Multiple Implementation Classes

Structuring Large BOs

  • Split into logical sub-classes
  • Use of final and partial implementations
  • Clear separation of determinations, actions, validations

Collaboration

  • Joint development on the same RAP BO
  • Namespace strategies and coordination

Draft Actions

Extended Possibilities

  • Custom actions in the draft context
  • Access to draft data (e.g., temporary status changes)
  • Automatic save triggers

Example

  • Action “ReleaseDraft” with final validation

Additional Save

When More Needs to Be Saved

  • Extended persistence logic in the save event
  • Use of post-persist hooks for additional processes

Unmanaged Save

Legacy Integration in Managed Scenario

  • Hybrid RAP: use Implementation Type Unmanaged
  • Reuse existing logic and DB structures
  • Combination of custom code and RAP BO

Custom Entities

When CDS Reaches Its Limits

  • Read-only access points without persistent tables
  • Query implementation via ABAP classes
  • Ideal for interfaces or external APIs

Virtual Elements

Extending App Logic

  • Calculated fields, UI-only information
  • Implementation via annotations and ABAP logic