What is RAP?
The ABAP RESTful Application Programming Model (RAP) is SAP's recommended framework for building transactional, Fiori-ready applications on S/4HANA and BTP. It replaces older models like BOPF and the ABAP Programming Model for Fiori.
RAP Architecture
RAP follows a three-layer architecture:
- Data Model (CDS Views) ÔÇö Define your data model with CDS entity definitions
- Business Logic (Behavior Definition) ÔÇö Implement CRUD operations, validations, and actions
- Service Exposure (Service Definition + Binding) ÔÇö Expose as OData V2/V4 services
Behavior Definition Example
managed implementation in class zbp_travel unique;
define behavior for ZI_Travel alias Travel
persistent table ztrav
lock master
authorization master ( instance )
{
create;
update;
delete;
field ( readonly ) TravelID;
field ( mandatory ) CustomerID, BeginDate, EndDate;
validation validateDates on save { field BeginDate, EndDate; }
determination setTravelID on modify { create; }
action ( features : instance ) acceptTravel result [1] $self;
}
Managed vs Unmanaged Scenarios
Managed
SAP handles all CRUD operations automatically. You only write validations, determinations, and custom actions. Best for new greenfield development.
Unmanaged
You implement all CRUD operations yourself. Best for wrapping existing legacy code or when you need full control.
Why RAP Matters
- Standard framework for S/4HANA extensions
- Automatic OData service generation
- Built-in draft handling for Fiori UIs
- Clean separation of concerns
- Testable with ABAP Unit