You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/development/specific/draft.md
+206-1Lines changed: 206 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -53,6 +53,211 @@ MODIFY ENTITIES OF i_salesordertp
53
53
COMMIT ENTITIES.
54
54
```
55
55
56
+
#### Editing a Standard SAP Draft BO
57
+
On S/4HANA or BTP ABAP Environment (Steampunk), many business objects already ship as draft-enabled BOs (e.g. `I_SalesOrderTP`). You don't build a BO and you don't create a draft table — SAP provides both. Your abap2UI5 app just calls the standard BO via EML, which sidesteps the whole lock-during-think-time problem.
58
+
59
+
The session can stay **stateless**: the draft survives between roundtrips in SAP's draft-shadow table, and the lock is held by the BO framework as long as the draft exists. Closing the browser without activating or discarding leaves the draft for the same user to resume later — no `set_session_stateful( )`, no `ENQUEUE_*`, no custom Z table.
client->message_box_display( `Activation failed — see application log.` ).
196
+
RETURN.
197
+
ENDIF.
198
+
199
+
COMMIT ENTITIES.
200
+
client->message_toast_display( `Sales order activated.` ).
201
+
client->nav_app_leave( ).
202
+
203
+
ENDMETHOD.
204
+
205
+
METHOD on_event_discard.
206
+
207
+
MODIFY ENTITIES OF i_salesordertp
208
+
ENTITY SalesOrder
209
+
EXECUTE Discard
210
+
FROM VALUE #( ( %key-SalesOrder = sales_order
211
+
%key-IsActiveEntity = abap_false ) )
212
+
FAILED DATA(failed)
213
+
REPORTED DATA(reported).
214
+
215
+
COMMIT ENTITIES.
216
+
client->nav_app_leave( ).
217
+
218
+
ENDMETHOD.
219
+
220
+
METHOD view_display.
221
+
222
+
DATA(view) = z2ui5_cl_xml_view=>factory( ).
223
+
view->shell(
224
+
)->page(
225
+
title = `Edit Sales Order — Standard BO Draft via EML`
226
+
shownavbutton = client->check_app_prev_stack( )
227
+
navbuttonpress = client->_event( `DISCARD` )
228
+
)->simple_form(
229
+
title = `Header (draft)`
230
+
editable = draft_open
231
+
)->content( `form`
232
+
)->label( `Sales Order`
233
+
)->input(
234
+
value = sales_order
235
+
enabled = abap_false
236
+
)->label( `Type`
237
+
)->input( client->_bind_edit( sales_order_type )
238
+
)->label( `Status`
239
+
)->input(
240
+
value = status_text
241
+
enabled = abap_false
242
+
)->button(
243
+
text = `Save Draft`
244
+
press = client->_event( `SAVE_DRAFT` )
245
+
enabled = draft_open
246
+
)->button(
247
+
text = `Activate`
248
+
type = `Emphasized`
249
+
press = client->_event( `ACTIVATE` )
250
+
enabled = draft_open
251
+
)->button(
252
+
text = `Discard`
253
+
press = client->_event( `DISCARD` ) ).
254
+
client->view_display( view->stringify( ) ).
255
+
256
+
ENDMETHOD.
257
+
258
+
ENDCLASS.
259
+
```
260
+
56
261
::: tip
57
-
A draft-enabled BO holds an exclusive lock for its owner as long as the draft exists, so the app can stay stateless and the user can resume work later. If you need additional locks for non-draft objects, see [Locks](./locks.md).
262
+
The field names (`SalesOrder`, `SalesOrderType`) match the released `I_SalesOrderTP` on current S/4HANA — on older releases the BO name or fields may differ. If no standard BO covers your object, define your own draft-enabled RAP BO (with its own `draft table z…_d`, `lock master`, etc.) and consume it the same way; see the [SAP RAP draft documentation](https://help.sap.com/docs/abap-cloud/abap-rap/draft). If you need locks for non-draft objects, see [Locks](./locks.md).
0 commit comments