Unmanaged RAP Part 3: Create, Update, Delete and Read Handlers
Preview · a free account unlocks the full lesson
Implement the unmanaged handler methods correctly: create into the buffer, partial updates with %control, delete including the create-then-delete case, a buffer-aware read method, and create-by-association for items.
In this lessonShow sectionsHide sections
Visual overview
Explanation
Part 2 gave the BDEF, the behavior pool skeleton, and the buffer class. This part fills in the handler methods, holding to a strict rule throughout: handlers only ever change lcl_buffer, and the legacy API is called exclusively by the saver, covered in Part 4.
Every handler follows a consistent signature pattern. The input is either "entities" (for create, update, create-by-association) or "keys" (for delete, read, lock, actions), and it's always a table — every row has to be processed, never just the first one assumed.
The output includes MAPPED, carrying new keys for each %cid; FAILED, carrying instances that failed along with %fail-cause; and REPORTED, carrying messages — with read methods also returning RESULT. %cid is the client's temporary ID for a new instance, while %tky is the transactional key of an existing one. %fail-cause tells RAP and the OData layer exactly why something failed: not_found maps to 404, unauthorized to 403, and there's also locked, conflict, and unspecific.
Create is comparatively simple here, since the key was already assigned by earlynumbering_create back in Part 1: create only builds the row, sets its defaults and admin fields, and inserts it into the buffer with flag C — it never calls the legacy API directly. Mandatory-field and business checks belong in validations or check_before_save rather than here, because a UI may legitimately create an empty draft first.
Update, and specifically %control, is the single most important detail in unmanaged RAP. OData updates are usually PATCH requests, where the client only sends the fields that actually changed, but RAP passes the full entity structure regardless, with the unsent fields left empty — so copying the whole structure onto the existing row would overwrite every unsent field with blank. %control is what prevents this: for each field, entity-%control-<Field> is set to if_abap_behv=>mk-on only when the client actually sent that field.
Create a free account to keep reading
You have read the opening of this lesson. A free ERPClimb account unlocks the rest of it, every other lesson and topic, and your learning history, so you can pick up exactly where you stopped. No card needed.
- Full explanation
- Code example
- Real project scenario
- Common mistakes
- Best practices
- Interview angle
One tap with Google works too. Every topic keeps its first lesson open to everyone.
Keep exploring
Interview questions on this topic
Check before use: lesson examples are educational, not a guarantee of correctness for your SAP edition or release. Sample code has not been executed on your SAP system. Confirm API availability, syntax, authorizations and business impact in an approved development or test environment.