Managed RAP Part 2: Numbering, Locking, ETags and Authorization
Preview · a free account unlocks the full lesson
Add the transactional controls to the Purchase Request object: a technical UUID plus a readable request number, pessimistic locks, optimistic ETag concurrency, and global and instance authorization.
In this lessonShow sectionsHide sections
Visual overview
Explanation
In Part 1 you built ZR_PurchReq with CRUD already working and no code written. It already carries three declarations that haven't been used yet: numbering, lock master, etag master and authorization master. This part works through each one and implements whatever actually needs code.
A good RAP business object usually carries two identifiers serving two different jobs: a technical key, RequestUUID, which is never shown to users, never changes, and is generated by the framework; and a semantic key, RequestID, something like 0000000042, which is what users actually search for and quote in emails. There are several numbering options for the technical key.
Managed early numbering, declared with "numbering : managed" on a UUID field, has the framework generate the UUID the moment the instance is created — the simplest option, and the one used here. Unmanaged early numbering, declared with "early numbering" in the entity header, requires implementing an earlynumbering_create method and assigning keys by hand during the interaction phase.
Late numbering, declared with "late numbering", uses a temporary key until save and assigns the final key in the saver method adjust_numbers — useful only when the final number must be gap-free and should only be drawn once the save is certain. External numbering simply has the consumer supply the key, with the field marked readonly : update.
For the semantic RequestID, this lesson uses a determination on save that draws a number from a number range object, ZPR_REQ (created in ADT as a Number Range Object, interval 01) — drawing the number at save time means a request that's never actually saved never consumes a number.
Locking provides pessimistic control. "lock master" on the root and "lock dependent by _Request" on the item mean that whenever anyone changes a request or any of its items, the framework locks the whole request, so a second user trying to edit the same request gets a lock error instead of silently overwriting it.
In managed RAP, no lock code needs to be written — the framework locks by the root key (in unmanaged RAP, the lock method has to be implemented by hand, as covered in the Unmanaged series).
Locks are exclusive and last until the transaction ends; with draft, covered in Part 4, the lock is held for the entire editing session of the draft.
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.