Skip to content

Commit cffff28

Browse files
committed
docs: add Draft Handling and Locks pages under Specifics
1 parent d97a4b1 commit cffff28

3 files changed

Lines changed: 86 additions & 0 deletions

File tree

docs/.vitepress/config.mjs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,8 @@ export default defineConfig({
159159
{ text: "Logging", link: "/development/specific/logging" },
160160
{ text: "Camera", link: "/development/specific/camera" },
161161
{ text: "CDS, EML", link: "/development/specific/cds" },
162+
{ text: "Draft Handling", link: "/development/specific/draft" },
163+
{ text: "Locks", link: "/development/specific/locks" },
162164
{ text: "Timer", link: "/development/specific/timer" },
163165
{ text: "Drag & Drop", link: "/development/specific/drag" },
164166
{

docs/development/specific/draft.md

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
---
2+
outline: [2, 4]
3+
---
4+
# Draft Handling
5+
6+
Draft handling lets users save unfinished work — for example, a half-filled form — without committing it to the active database state. With abap2UI5 you can drive RAP draft-enabled business objects directly through EML.
7+
8+
### Modify a Draft
9+
Use `MODIFY ENTITIES` with the `IN LOCAL MODE` and the draft addition to create or update draft instances:
10+
```abap
11+
MODIFY ENTITIES OF i_salesordertp
12+
ENTITY salesorder
13+
CREATE
14+
FIELDS ( salesordertype salesorganization )
15+
WITH VALUE #( ( %cid = `0001`
16+
%is_draft = if_abap_behv=>mk-on
17+
%data = VALUE #(
18+
SalesOrderType = `TA`
19+
SalesOrganization = `1010` ) ) )
20+
MAPPED DATA(ls_mapped)
21+
FAILED DATA(ls_failed)
22+
REPORTED DATA(ls_reported).
23+
```
24+
25+
### Activate a Draft
26+
Promote the draft to the active state with the `Activate` action and commit:
27+
```abap
28+
MODIFY ENTITIES OF i_salesordertp
29+
ENTITY salesorder
30+
EXECUTE Activate
31+
FROM VALUE #( ( %key = ls_key
32+
%is_draft = if_abap_behv=>mk-on ) )
33+
MAPPED DATA(ls_mapped_act)
34+
FAILED DATA(ls_failed_act)
35+
REPORTED DATA(ls_reported_act).
36+
37+
COMMIT ENTITIES BEGIN
38+
RESPONSE OF i_salesordertp
39+
FAILED DATA(ls_save_failed)
40+
REPORTED DATA(ls_save_reported).
41+
COMMIT ENTITIES END.
42+
```
43+
44+
For more on EML in abap2UI5 apps, see [CDS, EML](./cds.md).
45+
46+
::: tip
47+
Draft tables hold exclusive locks for the draft owner. Combine draft handling with [Locks](./locks.md) only when you also need backend lock objects outside of RAP.
48+
:::

docs/development/specific/locks.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
---
2+
outline: [2, 4]
3+
---
4+
# Locks
5+
6+
Business logic often needs to prevent two users from editing the same object at the same time. Because abap2UI5 runs stateless by default, locks held with `ENQUEUE` / `DEQUEUE` are released at the end of each roundtrip — so locking needs a deliberate approach.
7+
8+
### Lock with a Stateful Session
9+
Switch the session to stateful and call the lock function module. The lock survives subsequent roundtrips as long as the session stays stateful:
10+
```abap
11+
CALL FUNCTION `ENQUEUE_E_TABLE`
12+
EXPORTING
13+
tabname = `ZTEST`
14+
varkey = varkey
15+
EXCEPTIONS
16+
foreign_lock = 1
17+
system_failure = 2
18+
OTHERS = 3.
19+
20+
IF sy-subrc = 0.
21+
client->set_session_stateful( ).
22+
ELSE.
23+
client->set_session_stateful( abap_false ).
24+
ENDIF.
25+
```
26+
27+
Release the lock by ending the stateful session — for example on navigation away from the edit view:
28+
```abap
29+
client->set_session_stateful( abap_false ).
30+
client->nav_app_leave( ).
31+
```
32+
33+
A complete example is in sample `Z2UI5_CL_DEMO_APP_350`.
34+
35+
### Other Options
36+
Stateful sessions are only available on private and on-premise systems. For other deployments, infinite backend sessions can hold locks while the UI5 app keeps talking statelessly. See [Statefulness, Locks](../../advanced/stateful.md) for the alternatives and trade-offs.

0 commit comments

Comments
 (0)