I'm trying to synchronize objects between SAP and another system, where "ownership" of the objects switches back and forth.
I know that the non-SAP system can use the ENQUEUE_XYZ lock object function to keep SAP users out of the data while the non-SAP system "owns" the object, but I'm getting stuck when I want to replicate the changes in SAP. I have to DEQUEUE the lock object before I can call the BAPI or run the CALL_TRANSACTION to save the changes from the non-SAP system back into SAP. The problem is that there will be some (admittedly small) amount of time between my DEQUEUE and the BAPI or BDC's lock. This means that it is possible that someone else could grab the object and make a change during that time, and then my BAPI or BDC would overwrite that change.
Am I missing something about ENQUEUE/DEQUEUE here? I was hoping that SAP would realize that the same user that had originally requested the ENQUEUE was the one trying to do the update, but I guess this isn't working because the BAPI/BDC takes place in its own LUW. Any ideas would be appreciated.
SAP invented the LUW concept to get round the problem that you can't rely on database locks when you are running a transaction. Now we have the same type of problem when we want to group together a number of LUW, which are dependent on each other.
If you have complete control over the programs that might update your object, then you could create a new lock object and use and check that as the programs want to update. However, if there are some standard SAP transactions which also update the object, you'd have to make sure that they also used the same lock object - perhaps by a suitable exit.
I think there is no simple answer; I'd suggest you look carefully at the business requirements and see how they might be adjusted to fit in with SAPs locking concepts.
Dig Deeper on SAP ABAP
Related Q&A from Matthew Billingham
An SAP user needs to transfer customer purchase order spreadsheet data to SAP VA01 to create a new sales order. Continue Reading
An SAP user is trying to run a report in an SAP ALV Grid online and wants to know how to get the data in the report to appear along with the header. Continue Reading
A SearchSAP.com reader who is writing a program to update SAP tables wants to know how to make updates visible in a change log by using an SAP change... Continue Reading