‎2008 Dec 03 11:19 AM
Hello to All,
I'm facing the following problem :
I Have developed a z application that updates data via bapis.
When the user selects the appropriate data, i lock the data in order to prevent changes in the meanwhile from other users.
When the user saves the data i first unlock the objects and the call the bapis. As you understand, this technique has a flaw : If the bapi call is somehow delayed ( Because the system is compiling ) there is a gap between the unlock of the objects and the relock from within the bapi so probably an other user can edit the object and then the bapi will not be executed since it will not be able to lock the object.
So, the question is : Is there a way to pass/transfer the lock to the bapi ? In theory, the lock owner is the key to success something like this but, i can't figure it out.
The question more clearly is :
Material aaa
lock material aaa from within the z application.
call bapi to change material aaa without unlocking the material.
"Transfer" the lock to the bapi somehow by using the lock owner.
any ideas ??
‎2008 Dec 03 11:25 AM
Hi
To the best of my knowledge you can use IN UPDATE TASK and pass the value 2 or 3 to the scope then this will be farwarded to the Function module also
For further info please go through the KEY word documentation of IN UPDATE TASK
regards
Ramchander Rao.K
‎2008 Dec 03 11:26 AM
In update task is not an option since the bapi is not an update function.
‎2008 Dec 03 11:37 AM
Tried also "keeping logical unit of work" when calling the bapi.. No luck !
‎2008 Dec 03 11:57 AM
Step1) Lock record using FM or BAPI
Step2) Update the record
Step3) Unlock the record using FM or BAPI
‎2008 Dec 03 12:02 PM
I guess that you haven't understand my question..
1) Lock objects via Enqueue FM
2) Call bapi to change objects WITHOUT Unlocking
3) Unlock objects via Dequeue FM
Problem : Bapi says that data is locked by mysefl !!
‎2010 Mar 17 1:34 AM
hi Laurent Fournier
Have you solved this problem? could you please share with me how u solved...
Thanks
jai
‎2010 Mar 17 6:43 AM
Hi Laurent,
I understand your requirement, but i have a question which might help you take a different approach, the steps in your program are,
1) Lock objects via Enqueue FM
Now in step 1) when you try to lock the material "AAA", let's say it is locked by another user. What do you do?...you throw a message is locked by so and so user right?
So why don't you start from step (2) directly, in-case the material is locked, the BAPI would return the details in the "RETURNS" parameter, if it is not locked you can proceed with your changes.
2) Call bapi to change objects WITHOUT Unlocking
3) Unlock objects via Dequeue FM
Regards,
Chen
‎2010 Dec 23 2:00 PM
Dear Chen,
Logic Is :
1) start a report and enter a material number.
2) lock material
3) display data for this material.
4)edit displayed data for material ( this can take time from the end user )
5)unlock material
6) execute bapi.
So, as you understand, your proposal cannot work here since, if i let the bapi to check and lock,
the user will edit the material and probably in the end he will not be able to update the material since it will be locked from another user.
Also, the displayed data may have changed without a lock from within the z application.
Thanks .