Trying to synchronize objects between SAP and another system (ENQUEUE/DEQUEUE)

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.
DeeDeeCeeAsked:
Who is Participating?
 
Teehee99Connect With a Mentor Commented:
I think I see the problem now ...tell me if I have the chain of events correct .

1) You have manually enqueued once already before the CALL TRANSACTION and left the lock in place .
2) CALL TRANSACTION will do a complete SAP transaction including automatic locking . That auto lock complains that the object is already locked (from 1) ..so you have to dequeue b4 the CALL TRANSACTION .

Yes , that is how SAP locking is supposed to work due to LUW concept as you mentioned . You could create a brand new lock object (EZxxxx) on the same object for 1) but CALL <SAP> TRANSACTION and other SAP transactions would only check for the SAP lock object for 2) as the check is done against the lock object name . If 1) and 2) use the same lock object name then you get the problem you are seeing .So neither way locks the object how you want  .

To guarantee no dequeing b4 you are finished you would need to develop your own program/transaction that did the whole job without calling a new transaction or ABAP statement that starts a new LUW .
0
 
Teehee99Commented:
Hi ,
ENQUEUE lock objects are the method SAP uses to lock SAP business objects (tables/fields etc..) . They are seperate to database locks as the databse knows nothing about business objects . So in ABAP ;

1) MANNUALLY Call lock object/ENQUEUE function module for that business object and your user in SAP(all other SAP users are locked out via SAP transactions if enqueue is successful but anybody non-SAP can still update the tables via the db)

2) MANNUALLY Call update for your user in SAP
(creates update request that SAP will then pass to db . If the table entries are not locked at the db level (by non-SAP ) process update . Db locks are only placed once the SQL to update is generated and applied . Released when the SQL finishes .

3) MANNULLY CALL DEQUEUE
call dequeue function module for your user and that business object . If successful lock is released and any other SAP user can try to lock the object

*SO , you must do all your work (call BAPI etc..) between 1) and 3) . The update in 2) can be finished but you can still hold your lock until you have dome other work ...then do 3) Why do you have to dequeue first ?
0
 
DeeDeeCeeAuthor Commented:
Well, I'm dequeuing first because if I don't, the object is locked when I issue the CALL_TRANSACTION. That's what has me confused....
0
The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

 
Teehee99Commented:
I don't quite follow why from your description , so please explain your chain of events more clearly if I'm not understanding you correctly ...but can you not :

Call the lock object as SAP user ABC , do your SAP updates etc ... as SAP user ABC ...Keep the lock object (do not dequeue) , do your non-SAP updates via RFC/whatever  ..and when you get a final OK return code finally release with a dequeue .

Doing it this way using custom code and BAPI / function module /RFC calls rather than SAP transactions will allow you to control exactly when you dequeue rather than SAP dequeuing when the SAP transaction/LUW is complete .
0
 
DeeDeeCeeAuthor Commented:
That's exactly what I tried. And during the "do your SAP updates" part I call RFC_CALL_TRANSACTION and it doesn't run successfully because the object is locked (by me! argh!). Which seems to defeat the purpose of the whole enqueue/dequeue concept.... If you're saying that what I was trying to do SHOULD have worked, then I don't know what's going on.
0
 
DeeDeeCeeAuthor Commented:
Yes, you've got it exactly. I was afraid that was going to be the answer. I was just hoping there was some sneaky little trick that I hadn't thought of! Since this needs to be done via CALL TRANSACTION, it looks like there is not a foolproof method of accomplishing this.

Thanks very much for your help.
0
 
weandeeCommented:
Hi

I need to know how you lock the object from NON-SAP.
I created a Lock Object in SE11 and Allow RFC yet, it cannot lock the object. And I dont know where it goes wrong.

Could you guide me in doing RFC- remote-enabled coz im using VB.Net, SAP.Net Connector to connect to SAP.

Your help would be much appreciated.

Thank you.
0
All Courses

From novice to tech pro — start learning today.