04-08-2024 4:50 PM - edited 04-09-2024 7:07 AM
Hi,
We want to implement pessimistic lock in one of the custom RAP based application(OData V2) where if user A is editing the document & if at the same time user B is trying to edit the same document then system should give error as "The document is currently being processed by user".
User do not want to use optimistic lock, which lets user to go in edit mode and at the time of save system will checks the lock.
The similar functionality is already achieved in one of the standard Fiori app -- App ID
F3893 (Manage Sales Orders - Version 2) it is using pessimistic lock.
When user click on Edit button on object page, call goes to backend to check sales order is already locked or not. if it is locked then system is giving popup with error as it is already locked. However not able to understand how this is integrated into this particular app.
If anyone have any idea about this, appreciate your help in this.
The lock will be checked automatically as soon you go into the EDIT mode . There could 2 scenario here
1. Managed App : If you are using managed app , the lock check will be handle by framework and it will give you generic error " You can't edit this instance at the moment. It's currently locked.".
2. Unmanaged App : In your example , Manage Sales Order Version 2 i.e. an Unmanaged app , the lock check has to be handled explicitly by custom logic in the lock method . You need to throw the error by filling up the Failed and Reported Structure and it will be shown automatically on the screen .
BDEF : R_SALESORDERTP
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Amit,
Thanks for your response.
In my custom app which is unmanaged app, I have implemented the lock method & call is also going into lock method but on save button & not on edit button. When we are clicking on Edit button on object page, that time call is not going into backend to check the lock entry.
However in manage sales order app, when we are clicking on edit button, call is going into backend & giving error. Here, SAP has implemented below screenshot action in behavior projection which is getting called when we are clicking on edit button. but there is clue how they are calling this action on edit button.
Regards,
Santosh F.
Hi Santosh ,
I tried replicating the scenario with unmanaged and i am getting the lock method triggered as soon i click on edit button .
Dummy logic Implemented which i have followed :-
failed-zsa_r_material_2 = value #( ( matnr = keys[ 1 ]-Matnr ) ).
APPEND VALUE #( %msg = new_message_with_text( severity = if_abap_behv_message=>severity-error
text = 'Lock has been triggered' )
) TO reported-zsa_r_material_2.
Error :
I have used Unmanaged V4 app with draft enabled for this example .
Hi Amit,
User do not want to use draft functionality in the custom application. However when we use OData V4 then draft functionality must be enabled otherwise we will not be able to see Edit/Delete buttons.
But in Sales order app they have used OData V4 without draft functionality & they are able to see EDIT button in the app. How this is possible? Do you have any idea about this?
Regards,
Santosh
Hi,
Not sure , about how it has been done standard app . May be they have used additional UI5 code for this ,if see the BSP file there are custom views and controller , so might be the possibility it has been done from UI5.
But , you can use V2 if you do not want draft functionality it will work similarly .
User | Count |
---|---|
72 | |
9 | |
8 | |
7 | |
6 | |
6 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.