In an unmanaged RAP business object, who handles draft and locking: the framework or you? And if locking is generic, why do you get a lock method to implement?
Say your answer out loud first.
Practise another way
With draft enabled, the framework does the draft part: it writes the draft tables and provides Edit, Activate, Discard and Resume. I own everything about active data, including the lock.
The runtime decides when a lock is needed, for example before an update, a delete or an Edit, and calls my FOR LOCK method.
It cannot set the lock itself because it does not know my legacy tables or lock object, so I enqueue and report a foreign lock in FAILED.
Who does what in an unmanaged BO
- You: create, update, delete, actions and reads on active data, the transactional buffer, and the saver methods (
finalize,check_before_save,adjust_numbers,save,cleanup) that write through your legacy API. - Framework: the RAP runtime orchestration of the interaction phase and save sequence, and, with
with draft;, draft handling. The transactional engine writes the draft tables and implements the draft actions, so you never touch the draft table with SQL. You still declare the draft table and thetotal etag.
Locking: the runtime decides when, you decide how
METHODS lock FOR LOCK IMPORTING keys FOR LOCK block.
METHOD lock.
TRY.
DATA(lock) = cl_abap_lock_object_factory=>get_instance( iv_name = 'EZSTOCKBLK' ).
CATCH cx_abap_lock_failure INTO DATA(error).
RAISE SHORTDUMP error.
ENDTRY.
LOOP AT keys ASSIGNING FIELD-SYMBOL(<key>).
TRY.
lock->enqueue( it_parameter = VALUE #(
( name = 'BLOCK_ID' value = REF #( <key>-BlockID ) ) ) ).
CATCH cx_abap_foreign_lock INTO DATA(foreign).
APPEND VALUE #( %key = <key>-%key ) TO failed-block.
" plus a REPORTED message naming foreign->user_name
CATCH cx_abap_lock_failure INTO error.
RAISE SHORTDUMP error.
ENDTRY.
ENDLOOP.
ENDMETHOD.
lock masteron the root makes the method exist; children arelock dependent byand use the root's lock.- A foreign lock is a business situation:
failedplus a message with the other user's name. A technical lock failure is a dump. - Lock entries are removed when the transaction ends (commit, rollback or session end).
Why the generic engine cannot do it. In a managed BO RAP knows the persistent table and builds the lock itself. In an unmanaged BO the data sits behind your API: only you know which lock object protects it.
Usually the legacy application already has one, and you must reuse it so RAP users and old transactions block each other.
With draft. Editing an active instance creates a draft and takes an exclusive lock on the active instance, in an unmanaged BO through your lock method.
After a configurable time the lock expires, the draft becomes optimistic, and the total ETag decides whether Resume may continue it.
Managed variant. A managed BO can declare lock master unmanaged to take over only the locking, for example to reuse a legacy lock object, while everything else stays managed.
Separates draft persistence (framework) from active-data locking (developer), explains that the runtime calls FOR LOCK and why only the developer knows the lock object, and shows enqueue with foreign-lock handling.
Says the framework locks everything in unmanaged too, or leaves the generated lock method empty.
Leaving the generated FOR LOCK method empty. Everything works in a single-user test, and in production two users overwrite each other's changes.
- What happens when the exclusive draft lock expires?
- What is lock master unmanaged in a managed BO for?
- How do you show the user who holds the lock?
2 official pages and 3 prep guides. Confidence: high. Checked 3 Dec 2026.
- Prep guide Gives the question.
- Prep guide Gives the question.
- Prep guide Gives the question.
- Official page Backs the answer.
- Official page Backs the answer.