Skip to Content
author's profile photo Former Member
Former Member

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

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.

Add comment
10|10000 characters needed characters exceeded

6 Answers

  • Posted on Oct 08, 2011 at 06:59 PM

    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

    Add comment
    10|10000 characters needed characters exceeded

    • 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.

  • Posted on Oct 10, 2011 at 06:36 AM

    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.

    Add comment
    10|10000 characters needed characters exceeded

    • 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.

  • author's profile photo Former Member
    Former Member
    Posted on Oct 10, 2011 at 11:26 PM

    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

    Add comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Nov 20, 2013 at 08:19 PM

    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


    Add comment
    10|10000 characters needed characters exceeded

  • Posted on Nov 20, 2013 at 11:22 PM

    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

    Add comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jul 20, 2015 at 09:58 AM

    Hi Muthu

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

    Thanks

    Arjun

    Add comment
    10|10000 characters needed characters exceeded