Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

ENQUEUE_EVVBAKE is not working

Former Member
0 Likes
9,136

Hi Experts

I am having a problem, i am using the lock object ENQUEUE_EVVBAKE in BSP , Please find the sample code:

     CALL FUNCTION 'ENQUEUE_EVVBAKE'

       EXPORTING

         VBELN          = PF_VBELN

       EXCEPTIONS

         FOREIGN_LOCK   = 2

         SYSTEM_FAILURE = 3.

it is working fine in the debugging mode, When i press F8 or it comes out from the debugger system release lock object automatically.

Thanks

Arjun 

25 REPLIES 25
Read only

deepan_v_s
Active Participant
0 Likes
6,243

Hi Arjun,

This is due to the fact that the Sales Document is already locked by another.. Please check the user ID which is locking it and if is not your user id then ask the user to come out of edit mode.

Or else delete the lock via, SM12..

It might be also due to ENQUEUE is done properly and DEQUEUE FM is not called after completing editing of SD.

Regards,

Deepan Swaminathan.

Read only

0 Likes
6,243

Hi

This lock is done by the code i  have used . But in only debug mode after the FM called , But when I press F8 . It will release Lock automatically.

Read only

0 Likes
6,243

Hi

This lock is done by the code i  have used . But in only debug mode after the FM called , But when I press F8 . It will release Lock automatically.

Read only

0 Likes
6,243

Please execute the code without debugging and check the result.

Regards,

Deepan Swaminathan

Read only

sriram_korlepara
Participant
0 Likes
6,243

Hi,

I believe you have included DEQUEUE_EVVBAKE fm also next to this enqueue.

Try to regenerate the program and relogin again,test it.Some times this may be due to memory issues.

Let me know if the issue still persists.

Thanks,

Pawan.

Read only

0 Likes
6,243

Hi

I have put only ENQUEUE_EVVBAKE. If  i am running this FM in SE37 , It is doing the same. If i come out from this FM it will release the lock automatically


My requirement is to lock the by my program sales order until unless i will not release that lock.


Read only

0 Likes
6,243

Please use FM DEQUEUE FM in the code.

Follow these steps,

1. Use ENQUEUE FM.

2. Process the SD document and Save the document.

3.Once saving is done, please use the FM DEQUEUE_EVVBAKE, to release the lock.

Try this and it will solve the issue.

Regards,

Deepan Swaminathan.

Read only

Former Member
0 Likes
6,243

Hi all

I have design a custom UI via BSP. Now i want if user will open any sales order in UI than it should not be editable any other user in UI and SAP.

So i want to lock the sales order if that is open in UI.

Thanks

Arjun

Read only

0 Likes
6,243

Yes Arjun, i understand the requirement.

But what if the user saves the UI or closes the UI. In that case lock should be released.

If it is not released, then the lock will be there in the document forever. (Even if the same user tries to open the Document in different session, error message will be displayed informing that SD is already locked)

So you need to call the DEQUEUE FM, ince the user completes his work in UI.

Regards,

Deepan Swaminathan.

Read only

0 Likes
6,243

Hi Deepan

Exactly i have also develop a BSP to release the lock. But my first BSP is not working to lock the Sales Order. That is the main problem for me.

In the debug mode it will lock the SO after execution of SO, But when after FM execution when i press F8 it will release the lock automatically.

Regards

Arjun

Read only

0 Likes
6,243

Hi Arjun,

Place an external break point just before DEQUEUE FM and check if the Document is locked.

Check it from UI, Place external break point.

Regards,

Deepan.

Read only

0 Likes
6,243

Hi

I have put the break point ,yes the object is locked. But when i execute further it will release the lock automatically. I have also checked in SM12 also.

Even i have commented the DEQUEUE FM in my BSP but Don't know why the lock object is releasing.

Read only

sriram_korlepara
Participant
0 Likes
6,243

Hi Arjun,

Initailly the Enqueue Fm(incorporated by you) is locking the sale order.

First try to identify where the lock is getting released.

I believe there is some standard code which is releasing the lock.If you want to to lock it or release it as per your requirement,try to put your code next to standard code using some enhancements.

Since you are calling from portal,i cannot replicate the issue in my system

Read only

Former Member
0 Likes
6,243

Hi Everyone

Please provide me a solution.

Read only

0 Likes
6,243

Hi Arjun,

Have you tried the way that I suggested above.

regards,

Pawan.

Read only

Former Member
0 Likes
6,243

Hi All

I have found on thing, In the debugger it is working fine , Because Lock object is active for the session when we execute the debugger or F8 it will release the lock automatically.If we can keep that session that it is possible.

So now how can i make a session active ?

Thanks

Arjun

Read only

Juwin
Active Contributor
0 Likes
6,243

Thats my understanding too - Locks are released automatically when the program execution is finished.

Ideally, you shouldn't be locking the sales order when the person opens it in a browser. Because he may just close the browser window and your program may be still holding the lock on the order. My suggestion would be to change the design of the program ....

1. User opens the order

2. User makes changes to the order and presses save

3. This triggers PAI event

4. Lock the order, Make changes to order, Unlock order

5. If lock fails, then wait and repeat for a certain amount of time. If still not successful, then display message to user

5. Refresh user display

Thanks,

Juwin

Read only

Former Member
0 Likes
6,243

Hi

I also considered the close window case, At that time i have put the DEQUEUE FM.

I agreed with the logic Locks are released automatically when the program execution is finished. But How can i make that lock active?

If i can make that lock active , It will fulfill my requirement. At the close window time will release that lock



Thanks

Arjun

Read only

Juwin
Active Contributor
0 Likes
6,243

Problem is, there is no event triggered for "close window". So, you will not be able to clear the lock at that time.

Thanks,

Juwin

Read only

Former Member
0 Likes
6,243

Hi

If you want the lock to be carried onto the V1 processes you have to set the _SCOPE = '3'. By default it takes '2'.

Explanation : ( From SAP Documentation ).

http://help.sap.com/abapdocu_70/en/ABENSAP_LOCK.htm

When you set an SAP lock using the ENQUEUE function module, the value transferred to the _SCOPE entry parameter determines the lock duration. Depending on the formal parameter _SCOPE, you can release an SAP lock as follows:

  • If _SCOPE is set to 1, the lock is not linked to the current SAP LUW. You can release the lock either by calling the DEQUEUE function module whose formal parameter _SCOPE can have any value, or by terminating the program.
  • If _SCOPE is set to 2, the lock is linked to the current SAP LUW. In case CALL FUNCTION ... FOR UPDATE TASK has registered at least one update function module, the statement COMMIT WORK or ROLLBACK WORK releases the lock upon completion of the SAP LUW. When using COMMIT WORK, the update function releases the lock after processing the update function modules. This type of lock may persist beyond the end of a program until the update procedure has been completed.
  • If _SCOPE is set to 3, both the update function and the program must release the lock. The update function releases the lock as if _SCOPE had a value of 2. The program releases the lock as if _SCOPE had a value of 1. The entire release procedure is specified by the last user who released the lock.

If you want to release an SAP lock using the DEQUEUE function module independent of the update function, you must transfer a value to the formal parameter _SCOPE that is greater than or equal to the value transferred to the parameter of the same name for the ENQUEUE function module.

Besides the _SCOPE parameter, the entry parameters of a DEQUEUE function module correspond to those of the ENQUEUE function module. You can then use the additional parameter _SYNCHRON to specify whether the release of the lock should be delayed until the program processing continues.

R

Read only

0 Likes
6,243

Hi Rudra

I have done this, But its not working. Please help me how can i make the lock active after execution?

Thanks

Arjun

Read only

0 Likes
6,243

Hi again,

Oh. I see.. You want the lock to be active even after your execution. Right?

Since you are using the standard lock. After execution when the update modules are processed correctly the lock will be released. as SAP uses the same lock object too  and doing the dequeue for you even when send as _SCOPE = '3'.

If you want the lock to stay active after you should go for a different custom lock object.

But in that case you should handle the dequeue functionality by yourself.

R

Read only

max_anjos
Explorer
0 Likes
6,243

Hi!

Did you Try this?

CALL FUNCTION 'ENQUEUE_EVVBAKE'

       EXPORTING

         MODE_VBAK = 'X'

         VBELN          = PF_VBELN

       EXCEPTIONS

         FOREIGN_LOCK   = 2

         SYSTEM_FAILURE = 3.

Read only

Former Member
0 Likes
6,243

Hi

I have tried with MODE, Its not keeping the lock object active after closing the session.

Thanks

Arjun

Read only

former_member253659
Discoverer
0 Likes
6,243

Dear Arjun,

Try to use 'Commit' After locking.

               Or

Try with custom lock.

Regards

Ravi