Link to home
Start Free TrialLog in
Avatar of DeeDeeCee
DeeDeeCee

asked on

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.
Avatar of Teehee99
Teehee99

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 ?
Avatar of DeeDeeCee

ASKER

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....
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 .
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.
ASKER CERTIFIED SOLUTION
Avatar of Teehee99
Teehee99

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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.
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.