RAP (RESTful ABAP Programming Model)
SAP's strategic, HANA-optimized model for building transactional business objects and Fiori/OData services in S/4HANA Cloud and on-premise.
RAP is how transactional apps are built in S/4HANA today. It replaces BOPF and the practice of writing business logic inside function modules.
RAP is like a well-defined assembly line for building furniture (business objects) with mandatory quality checkpoints (validations, determinations) at fixed stations, versus the old approach of a single craftsperson (a BAPI function module) building the whole piece by hand with no enforced checkpoints - RAP's managed mode is like using the factory's standard automated frame and finish; unmanaged mode is bringing your own custom frame but still running it through the factory's checkpoint stations.
Key Concepts
CDS data model what the object is -- interface and projection views
behavior definition what may be done to it
behavior implementation the logic, in ABAP classes define behavior for ZI_Travel alias Travel
persistent table ztravel
lock master
{
create; update; delete;
field ( readonly ) TravelId;
field ( mandatory ) CustomerId;
action acceptTravel result [1] $self;
validation checkDates on save { field BeginDate, EndDate; }
determination setStatus on modify { create; }
} determination sets a value when something changes
-- "status becomes OPEN when the record is created"
validation refuses a save when a rule is broken
-- "end date must be after begin date"
action an operation beyond create/update/delete
-- "accept this travel request" managed RAP generates the save logic. For a new object over
a table you control.
unmanaged you write the save sequence yourself. For wrapping
existing tables and legacy logic that does not fit
RAP's assumptions. behavior + CDS -> service definition -> service binding -> OData