Skip to content

Commit 3177d38

Browse files
committed
docs(locks): number strategy sections
So readers can see at a glance how many locking strategies are available.
1 parent b79c008 commit 3177d38

1 file changed

Lines changed: 8 additions & 8 deletions

File tree

docs/development/specific/locks.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ In classic SAP GUI, a transaction like `VA02` calls `ENQUEUE_EVVBAK` and the loc
1212

1313
The patterns below combine in different ways. The examples use the sales order header table `VBAK` and its standard enqueue object `EVVBAK`, but the same shapes apply to any table. All snippets have a complete, copy-paste-ready demo class — sample numbers are linked next to each section.
1414

15-
#### No Locking
15+
#### 1. No Locking
1616
The minimal starting point — the user edits and saves, no lock and no conflict check. Last save wins, silently. Fine for personal sandboxes and throwaway demos, but rarely what you want in production. See sample `Z2UI5_CL_DEMO_APP_S_07`.
1717

18-
#### Lock at Save
18+
#### 2. Lock at Save
1919
Do not hold a lock while the user thinks. Acquire it the moment they save, write, commit, and release — all in one short roundtrip:
2020
```abap
2121
METHOD on_event_save.
@@ -49,7 +49,7 @@ ENDMETHOD.
4949

5050
The lock exists for milliseconds, so this scales — but two parallel saves can still race if the timestamps line up, and the second one silently overwrites the first. See sample `Z2UI5_CL_DEMO_APP_S_08`.
5151

52-
#### Optimistic Check
52+
#### 3. Optimistic Check
5353
On read, remember the record's change timestamp. On save, re-read and reject if it shifted in the meantime — the same idea as an HTTP ETag:
5454
```abap
5555
METHOD data_read.
@@ -78,10 +78,10 @@ No lock is held during the edit phase, so this scales to many concurrent users a
7878

7979
Pick a column that *always* updates on writes. If anyone writes the table bypassing `AEDAT` / `UPD_TMSTMP`, the check silently misses real conflicts.
8080

81-
#### Combined (recommended default)
81+
#### 4. Combined (recommended default)
8282
**Lock at Save** plus the **Optimistic Check** is the safest stateless pattern and the sensible production default — the enqueue serializes parallel saves of *this* app, the timestamp check catches everyone else. See sample `Z2UI5_CL_DEMO_APP_S_10`.
8383

84-
#### Stateful Session
84+
#### 5. Stateful Session
8585
For classic SAP GUI-like behaviour, switch the session to stateful and call the lock function module on init. The lock survives subsequent roundtrips as long as the session stays alive:
8686
```abap
8787
IF client->check_on_init( ).
@@ -123,7 +123,7 @@ See samples `Z2UI5_CL_DEMO_APP_S_11` and `Z2UI5_CL_DEMO_APP_350` for complete ex
123123
Each active user pins a work process. Use stateful sessions only for low-traffic, internal apps. Always pair `set_session_stateful( )` with an explicit `set_session_stateful( abap_false )` on every exit path — otherwise a leaked enqueue blocks future users until the session times out.
124124
:::
125125

126-
#### Soft Lock
126+
#### 6. Soft Lock
127127
A soft lock is a row in a custom Z table marking *"user X is editing object Y"*. It is **not** enforced by the SAP kernel — only your app code respects it — so use it for UX feedback ("locked by Alice since 09:32") and always layer it on top of a real save-time guard. A minimal schema:
128128

129129
| Field | Type | Description |
@@ -135,10 +135,10 @@ A soft lock is a row in a custom Z table marking *"user X is editing object Y"*.
135135

136136
A user closing the browser without pressing *Release* leaves the row behind, so add a cleanup job that deletes entries older than, say, 30 minutes. See sample `Z2UI5_CL_DEMO_APP_S_12` (with the matching `Z2UI5_SAMPLE_01` table).
137137

138-
#### RAP Drafts
138+
#### 7. RAP Drafts
139139
On modern releases, RAP draft-enabled business objects manage locking for you: the draft holds an exclusive lock for its owner while the user keeps editing — no stateful session, no `ENQUEUE_*` call. If a released SAP BO already covers your object, this is usually the simplest path. See [Draft Handling](./draft.md).
140140

141-
#### Lock-Manager Add-on
141+
#### 8. Lock-Manager Add-on
142142
The community add-on [**lock-manager**](https://github.com/abap2UI5-addons/lock-manager) wraps the lock logic in a reusable class — including stale-lock cleanup and a "locked by X since…" message for the user. Install it like any other [add-on](../../resources/addons.md) and call it instead of writing the boilerplate yourself.
143143

144144
#### Choosing a Strategy

0 commit comments

Comments
 (0)