RAP = Framework for building OData services on SAP BTP ABAP Environment (a.k.a. Steampunk) or on S/4HANA.
- It allows you to expose business objects via REST APIs.
- A Business Object (BO) in RAP is defined via CDS Views + Behavior Definition + Behavior Implementation.
Managed vs. Unmanaged Scenarios
Managed Scenario
In this case, RAP framework manages the persistence (DB operations) automatically.
-
You define your CDS entity and annotate it.
-
RAP auto-generates all CRUD (Create, Read, Update, Delete) operations.
-
Developer effort = Minimal, only add custom logic if needed.
-
RAP uses the ETag handling, draft handling, transactional behavior automatically.
When to use:
- When your DB tables are new or not yet used elsewhere.
- For greenfield developments (new business objects).
Example (Managed Scenario)
CDS Entity:
define root view entity Z_I_SalesOrder
as select from zsalesorder
{
key salesorder_id,
customer,
order_date,
status
}
Behavior Definition (Z_I_SalesOrder.behavior):
managed implementation in class zbp_salesorder unique;
define behavior for Z_I_SalesOrder alias SalesOrder
persistent table zsalesorder
lock master
draft;
create;
update;
delete;
endbehavior;
RAP automatically knows how to insert/update/delete records in zsalesorder.
Unmanaged Scenario
In this case, developer controls persistence logic (you implement CRUD manually).
- RAP only provides the framework & metadata.
- You must implement the behavior in an ABAP class (behavior handler).
- Useful when business logic is complex or DB table is legacy (used by other apps, needs validations, custom logic, or external system integration).
When to use:
- When you already have existing tables and need custom save logic.
- For brownfield scenarios (extending existing business processes).
Example (Unmanaged Scenario)
CDS Entity
define root view entity Z_I_SalesOrder
as select from zsalesorder_legacy
{
key salesorder_id,
customer,
order_date,
status
}
Behavior Definition (Z_I_SalesOrder.behavior):
unmanaged implementation in class zbp_salesorder unique;
define behavior for Z_I_SalesOrder alias SalesOrder
lock master;
create;
update;
delete;
endbehavior;
Behavior Implementation (ABAP Class):
CLASS zbp_salesorder DEFINITION PUBLIC FINAL CREATE PUBLIC.
PUBLIC SECTION.
INTERFACES if_abap_behavior_handler.
ENDCLASS.
CLASS zbp_salesorder IMPLEMENTATION.
METHOD if_abap_behavior_handler~create.
” Custom logic for inserting into zsalesorder_legacy
ENDMETHOD.
METHOD if_abap_behavior_handler~update.
” Custom logic for updating existing orders
ENDMETHOD.
METHOD if_abap_behavior_handler~delete.
” Custom logic for deletion
ENDMETHOD.
ENDCLASS.