Application Development 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: 

How to Lock/Enqueue objects and keep it locked even after the dialog ends

Former Member
0 Kudos

What is the best way to lock/enqueue an object even after the dialog that created the lock ends. Only an explicit dequeue call on that object should be able to unlock/dequeue that object.

Any idea or solution would be greatly appreciated.

10 REPLIES 10

Clemenss
Active Contributor
0 Kudos

Hi Thanigaivelan M... ,

call a function in new or background task, let it do the enqueue. But then I have no idea on how to dequeue except killing the task.

Regards

Clemens

matt
Active Contributor
0 Kudos

At the point you want it to dequeue, you could write an entry to a table. The FM would see this (looking for it every five minutes), and then dequeue and terminate.

It's also possible to register to an event that gets triggered when a tx ends. At this point, you could reapply the lock.

What's the development scenario? Why are you wanting to do this? Perhaps other ideas might work.

rajesh_paruchuru
Active Participant
0 Kudos

What is the best way to lock/enqueue an object even after the dialog that created the lock ends. Only an explicit dequeue call on that object should be able to unlock/dequeue that object.

>

> Any idea or solution would be greatly appreciated.

If you can manage your updates in update tasks, you may be able to control the dequeue by using the '_SCOPE'

parameter of the FM generated for enqueue.

I may be completely out of context here, however, I believe it is worth investigating this extract of the SAP help

SCOPE = 3: The lock or lock release is also passed to the update program. 
The lock must be removed in both the interactive program and in the update program.

as explained [ here.|http://help.sap.com/saphelp_47x200/helpdata/en/4f/991f82446d11d189700000e8322d00/frameset.htm]

-Rajesh.

0 Kudos

You can register an event handler for CL_SYSTEM_TRANSACTION_STATE TRANSACTION_FINISHED. This will trigger when your transaciton ends.

You might like to check out [this article|http://searchsap.techtarget.com/tip/How-to-do-additional-dialog-processing-after-SAP-COMMIT-WORK-statement] I wrote a while back.

Edited by: Matt on Oct 10, 2011 10:42 AM

0 Kudos

You can register an event handler for CL_SYSTEM_TRANSACTION_STATE TRANSACTION_FINISHED. This will trigger when your transaciton ends.

>

> You might like to check out [this article|http://searchsap.techtarget.com/tip/How-to-do-additional-dialog-processing-after-SAP-COMMIT-WORK-statement] I wrote a while back.

>

> Edited by: Matt on Oct 10, 2011 10:42 AM

Thanks Matt, the solution is indeed nice and clean, i'm sure that I would be using this technique in future.

-Rajesh.

Former Member
0 Kudos

The responses so far talks about ways to find when the dialog/transaction completes so I can dequeue.

Sorry, if my question wasn't clear the first time.I am looking for ways to keep the enqueue entry active on the enqueue server even after the call/dialog/transaction to enqueue completes processing.

Situation:

When an external system is calling the enqueue RFC to lock an entry, the call to SAP from external system creates the lock. When the called RFC completes processing and control goes back to the external system, the enqueue is automatically released since the RFC that made the enqueue request completed processing in SAP.

I want to keep the enqueue entry active on the enqueue server even after the call from external system completes. I will make a follow up call from the external system to dequeue when I am ready to dequeue it.

Thanks

matt
Active Contributor
0 Kudos

That's why it's usually a good idea to give the full scenario.

You need to use qRFC. Or a stateful webservice.

matt

Former Member
0 Kudos

Dear Muthu,

have you been able to find a solution ? We are facing the same issue to lock object from an external application (#NET) and manage locks from external application

Matthew, would you please be kind and detail when you say

You need to use qRFC. Or a stateful webservice.

Thanks in advance, any help would be appreciated

kind regards,

jamal


janisar_munshi
Participant
0 Kudos

Try using Following code, it worked for me...

CALL

FUNCTION 'FUNCTION_NAME'    "USE THE RFC
STARTING NEW TASK lv_cur_ins               "'MR_UPLOAD'
        DESTINATION IN GROUP DEFAULT
        CALLING task_complete
        ON END OF TASK
          EXPORTING
            lt_data       = lt_data
            iv_rdate      = me->gv_date
          TABLES
            et_error      = lt_data_err
            et_appl_error = lt_appl_err
          EXCEPTIONS
          communication_failure  = 1
          system_failure         = 2
          OTHERS                 = 3.
      ENDIF"endif last
    ENDLOOP.

    WAIT UNTIL gv_inst_completed = gv_inst_started
    UP TO LV_WAIT SECONDS.

Regards,

Janisar

Former Member
0 Kudos

Hi Muthu

I am also facing the same problem, After execution how to keep active the lock object. Please share the solution.

Thanks

Arjun