Lock object

Hi,
In a program to update the database table I need to lock the table Is this correct to use enqueue functional module before the modify & commit statement
and dequeue functional module after
modify & commit statement.

Hi,
We can use the function modules ENQUEUE_E_TABLE for locking tables and the function module DEQUEUE_E_TABLE for unlocking tables. With this method, we don't need to lock objects in order to lock the tables. In other words, any table can be locked/unlocked using these function modules.
report zsubhas_enqueue.
* testing the locking of tables...
data:
varkey like rstable-varkey.
varkey = sy-mandt.
* locking the tables............................
call function 'ENQUEUE_E_TABLE'
exporting
* MODE_RSTABLE = 'E'
tabname = 'MARA'
varkey = varkey
* X_TABNAME = ' '
* X_VARKEY = ' '
* _SCOPE = '2'
* _WAIT = ' '
* _COLLECT = 'X'
exceptions
foreign_lock = 1
system_failure = 2
others = 3
case sy-subrc.
when 1.
message i184(bctrain) with 'Foreignlock'.
when 2.
message i184(bctrain) with 'system failure'.
when 0.
message i184(bctrain) with 'success'.
when others.
message i184(bctrain) with 'others'.
endcase.
* unlocking the table...............
call function 'DEQUEUE_E_TABLE'
exporting
* MODE_RSTABLE = 'E'
tabname = 'MARA'
varkey = varkey
* X_TABNAME = ' '
* X_VARKEY = ' '
* _SCOPE = '3'
* _SYNCHRON = ' '
* _COLLECT
Regards
Sudheer

Similar Messages

  • Lock object is not working automatically

    Hi experts,
    i have a problem , A table is updated by a program which is used by multiple user . I have used lock function module 'ENQUEUE_E_TABLE ' and 'DEQUEUE_E_TABLE' for that . when updation section occurs first user which come first go through it and for rest users amessage cones 'table is locked by XYZ user' . When first completes the updation resr users is not updating automatically they stand at that position where message comes. How to solve this issue?
    Avadhesh Chandra

    Hi,
    We can lock the table before updating the entries. Two types of locks are there.
    1. To lock the entire table. Here when the table is locked by one program, another program will not be able to modify it.
    2. To lock the particular record only. Here when the record is locked by one program, the other program can modify records other than the one locked.
    For option 1
    Use the FM ENQUEUE_E_TABLEE to lock the table and FM DEQUEUE_E_TABLEE to unlock table.
    For option 2
    Go to SE11. There enter the name of your lock object and create it. Next screen you have to mention which field you want to lock.
    For more info. on LOCK OBJECTS go to
    http://help.sap.com/saphelp_nw2004s/helpdata/en/cf/21eea5446011d189700000e8322d00/content.htm
    If you want to lock the entire table, then use the FM said in option 1 in DO-ENDDO loop. 
    Run the loop till it gets successful (sy-subrc = 0)
    DO.
    *Call the FM.
    IF sy-subrc = 0.
        EXIT.
    ENDIF.
    ENDDO.
    If you want to just try some number of times rather than keep on looping then can use for eg: DO 100 TIMES.

  • Ora-04021 timeout occurred while waiting to lock object

    Hai All
    When adding a column into a table then an error comes error
    Error Message:
    ORA-04021: timeout occurred while waiting to lock object .....
    How it happens ...what is the solution....please help
    Shiju..

    Hi
    Identify the session that is using this object, kill it and then perform the ALTER table... or wait until the session that is accessing this table release it.
    Rgds
    Adnan

  • JDAPI Error: ORA-04020: deadlock detected while trying to lock object

    I have written a JDAPI program to perform read-only impact analysis and report any problems.
    The following error is occurring:
    "A deadlock among DDL and parse locks is detected.
    This deadlock is usually due to user errors in the design of an application or from issuing a set of concurrent statements which can cause a deadlock.
    ORA-04020: deadlock detected while trying to lock object /NSPC6/CHECK_FOR_FORM_CHANGE"
    The error refers to a procedure in a PL/SQL library.
    In one case the error occurred after my final "end of processing" message, which is followed only by a call to "Jdapi.shutdown()".
    Any ideas?
    Thanks,
    Neville Sweet.

    I have written a JDAPI program to perform read-only impact analysis and report any problems.
    The following error is occurring:
    "A deadlock among DDL and parse locks is detected.
    This deadlock is usually due to user errors in the design of an application or from issuing a set of concurrent statements which can cause a deadlock.
    ORA-04020: deadlock detected while trying to lock object /NSPC6/CHECK_FOR_FORM_CHANGE"
    The error refers to a procedure in a PL/SQL library.
    In one case the error occurred after my final "end of processing" message, which is followed only by a call to "Jdapi.shutdown()".
    Any ideas?
    Thanks,
    Neville Sweet.

  • Unable to delete Transport Request which contain locked objects

    Hi all,
    I need to delete  some unusable transport requests but as they contain locked objects, it's not possible to delete them. Release operation is just allowed. After releasing these transport requests, I can not find them any more in queue. Please help to find these  transport requests which are released and also provide a solution to delete instead of releasing them.
    Thanks in advance,
    Sanaz.

    Hi,
    Thank you for the reply.
    1. What do you mean by transport request , Shipment Request, Shipment Order or Tour.
    A. I mean requests which can be transported between SAP Systems using TMS (Transport Management System).
    2. What are the objects which has been locked and due to that you are facing this problem.
    A. There are diffrent object types. For examle some customizing have booen done or SAP Note correction has been implemented, ... Therefore some objects have been locked due to these operations
    3. Let's say if it's an freight Unit, then Pls confirm that System dump / error is not the cause for this.
    A. I have no idea about "Freight Unit".
    Thanks,
    Sanaz.

  • Error while lock object creation

    Hi
    When I tried to create a lock object, I get the following error.
    Error: "Total length of lock argument for table XXXXXXXXX longer than 150"
    I have 3 tables in which Table1 is the check table for the value tables (Table2 & Table3). During the process of deletion of a record from Table1 (CT) I need the lock tobe established on value tables and then I delete all the corresponding entries in value tables are also deleted.
    Would like to know If there is any other std ways of doing this ? and
    Solution to overcome the error.
    Regards
    Karthick

    Hi,
    I think the error is becoz you have given too many LOCK parameters in the lock object. the total length of the PARAMTERS of lock object should not exceed 150.
    By default all the KEY fields will be taken as Lock paramters, so your table key's length is more than 150.
    Also why dont you create 3 lock objects for each table and then use only KEY's of each table as LOCK PARAMETERS.
    Then Lock T1 record first then lock T2 and T3 records, then delete records from T2 and T3.
    Then you delete T1 record.
    The execute DEQUEUE_ALL.
    Regards,
    Sesh

  • Report to find Locked objects in sap system

    Hi All,
    does anyone know the report to find out the locked objects in an sap system?
              or
    name of the table that stores locked objects ?
    or any other way through which we can find the number of locked objects ?
    Thanks and regards
    Abdul Hadi

    Hi,
    You can unlock locked objects in transaction SE03.
    Click on Display Repaired objects.
    You can see all the objects that are locked.
    To unlock you can select the particular object and click on Unlock.
    Do reward points if the answer to your question is met.
    Regards
    Suhas

  • Patch 9239090 - ORA-04021: timeout occurred while waiting to lock object

    Hello Guys,
    I need help urgently to comlete an upgrade of ebs 12.1.1 to 12.1.3.
    We are upgrading ebs 11i to 12i going live this weekend. We have encountered "ORA-04021: timeout occurred while waiting to lock object" on patch 9239090 with two Workers:
    In adctrl:
    1 Run AutoPatch R120 AFUTLGRS.pls FAILED
    2 Run AutoPatch R120 AFUTLOGS.pls FAILED
    sqlplus -s APPS/***** @/u02/applfinp/apps/apps_st/appl/admin/OFPROD/out/p001invok.sql
    Connected.
    create or replace package wf_bes_cleanup AUTHID CURRENT_USER as
    ERROR at line 1:
    ORA-04021: timeout occurred while waiting to lock object
    I have done everything everything imaginable but cannot get pass these 2 failed workers.
    1) I have checked are there are no locks blocking on any objects:
    select s1.username || '@' || s1.machine
    || ' ( SID=' || s1.sid || ' ) is blocking '
    || s2.username || '@' || s2.machine || ' ( SID=' || s2.sid || ' ) ' AS blocking_status
    from v$lock l1, v$session s1, v$lock l2, v$session s2
    where s1.sid=l1.sid and s2.sid=l2.sid
    and l1.BLOCK=1 and l2.request > 0
    and l1.id1 = l2.id1
    and l2.id2 = l2.id2 ;
    2) I also checked and there is space in the database.
    3) From adctrl, I have tried restarting the jobs one by one but the worker 1 hangs at and eventually fails on several (12) attempts.
    4) The solution on Doc ID 1291064.1 is not the problem:
    SQL> select SUPPLEMENTAL_LOG_DATA_MIN, SUPPLEMENTAL_LOG_DATA_PK, SUPPLEMENTAL_LOG_DATA_UI, FORCE_LOGGING
    from v$database;
    SUPPLEME SUP SUP FOR
    NO NO NO NO
    5) Manual execution still gave ORA-04021:
    sqlplus -s APPS/apps @/u02/applfinp/apps/apps_st/appl/admin/OFPROD/out/p001invok.sql
    sqlplus -s APPS/apps @/u02/applfinp/apps/apps_st/appl/admin/OFPROD/out/p002invok.sql
    6) The alert log has no related errors
    7) I Finally, after over 6 hours of waiting, I could only get the patch to continue after by using adctrl option 8 to skip these two workers.
    After proceeding, I have yet hit two more errors and now stuck:
    I have hit another error with the same patch:
    create or replace package body FND_LOG as
    /* $Header: AFUTLOGB.pls 120 ...
    AD Worker error:
    ORA-04021: timeout occurred while waiting to lock object
    Unable to process file in PACKAGE mode.
    Not converting file for Invoker's Rights because it appears to be a package body creation script (based on the filename).
    File is: /u02/applfinp/apps/apps_st/appl/fnd/12.0.0/patch/115/sql/AFUTLOGB.pls
    AD Worker warning:
    Product Data File
       /u02/applfinp/apps/apps_st/appl/admin/xniprod.txt
       does not exist for product "xni".
      This product is registered in the database but the above file does not exist in APPL_TOP.  The product will be ignored without error
    AD Worker error:
    The following ORACLE error:
    ORA-04063: package body "APPS.FND_LOG" has errors
    ORA-06508: PL/SQL: could not find program unit being called: "APPS.FND_LOG"
    ORA-06512: at "APPS.FND_FUNCTION", line 834
    ORA-06512: at "APPS.FND_MENU_ENTRIES_C_DELTRG", line 4
    ORA-04088: error during execution of trigger 'APPS.FND_MENU_ENTRIES_C_DELTRG'
    Can I stop and restart this patch 9239090?

    Hello,
    I later executed the failed jobs or scripts manually (successfully) for the patch to continue
    sqlplus -s APPS/apps @/u02/applfinp/apps/apps_st/appl/admin/OFPROD/out/p001invok.sql
    sqlplus -s APPS/apps @/u02/applfinp/apps/apps_st/appl/admin/OFPROD/out/p002invok.sql
    The patch ended with the following :
    The following Oracle Reports objects did not generate successfully:
    ap reports/US APXARATE.rdf
    ar reports/US ARXCTA.rdf
    fa reports/US FASRSVED.rdf
    ont reports/US OEXOEORD.rdf
    pa reports/US PAXACMPT.rdf
    pa reports/US PAXALRUN.rdf
    pa reports/US PAXACRPT.rdf
    pa reports/US PAXCPGAL.rdf
    pa reports/US PAXPCRFD.rdf
    The patch execution ended but the patch number is not record in apps.ad_bugs table:
    select TO_CHAR(CREATION_DATE,'dd-Mon-yyyy, hh24:mm:ss'), BUG_NUMBER from apps.ad_bugs where bug_number in ('9239090');
    no rows selected
    JFI
    Patches located in ad_applied_patches to which there is no a corresponding record in ad_bugs:
    SQL> SELECT a.patch_name, TO_CHAR(max(a.last_update_date),'dd-Mon-yyyy, hh24:mm:ss')
    2 FROM applsys.ad_applied_patches a
    3 WHERE NOT EXISTS (SELECT '1'
    4 FROM ad_bugs b
    5 WHERE b.bug_number = a.patch_name)
    6 group by a.patch_name;
    PATCH_NAME TO_CHAR(MAX(A.LAST_UP
    9239090 26-Oct-2013, 00:10:27
    AutoConfig 25-Oct-2013, 17:10:51
    merger9179588 25-Oct-2013, 11:10:30
    merger_post_5903765 27-Apr-2013, 23:04:45
    mergeu6678700 25-Oct-2013, 16:10:09
    What could have happened that this was not recorded in ad_bugs?
    How to I get this recorded in the ad_bugs table?
    Thanks
    Mathias

  • Lock objects to text

    Does anyone know of a way to lock floating objects to text in a Pages09 document? I love the way Pages deals with floating objects, so much better than Word, but I'd like to be able to lock individual or grouped objects (images, text boxes) to a specific paragraph, so they move together during editing. I see how to lock objects to a specific location on a page, but this is not what I want.

    What you are requesting is called an anchor and it is a feature that I too wish Pages had. For now, if you want an object to flow with our edited text, the only choice is an inline object. However I have found that either Pages 09 has better inline text wrapping or I totally missed that Pages 08 got it. Try placing an object inline, setting its text wrapping to on, and then play with the options. You might find that you can get what you want this way.
    I'm in the midst of creating a large set of tutorials with lots of pictures of menus, palettes, and the like. Each tutorial is from 5 to 12 pages long. Even though I'm not getting the exact placement I want using this method, it is close enough for me to use while I'm writing and editing. When I'm finished with a tutorial I've been going back and making some of them floating objects again and tweaking their locations a bit. A bit of a kludge but we work with what we've got, eh?

  • Create lock object with fun command

    Hallo,
    Is it possible to create a lock object with the fun command? I tried to use:
    FUN ( ENQUEUE _<lockobject> , <interface> ).
    When I fill the importing parameters, execute the script and afterwards refresh the interace than the import parameters are empty. Is there a way to create a lock object with the fun command or at least with inline abap?
    regards,
    Wolfgang

    Hi Wolfgang,
    in general your way of including the FUN command was correct.
    The loss of import parameter values must have been caused by some other reason, not related to the invoke of enqueue. Maybe try it again.
    If, for any reason, using FUN is not possible, it's always an alternative to use ABAP. .... ENDABAP. with correct ABAP coding inbetween (e.g. CALL FUNCTION ...).
    Nevertheless regarding enqueue you need to consider, that the lock you set by running eCATT test scripts in this way, will last (only) as long as the session in which the function was called is active. Means, it lasts as long as you do not close the SECATT transaction (/n or similar) and not use commands like RESCON in your test script. Check your locks with transaction sm12.
    Be aware, that interfering with an applications lock handling and strategy might also harm running transactions or the data processed by this transactions. Usually there is no need to call the enqueue modules from a test.
    Best Regards
    Jens

  • About lock object

    I have one TABLE with TABLE MAINTENANCE GENERATOR 
    and it has also LOCK OBJECT.
    Now I have adjusted the table by making some normal fields as primary keys
    and regenerated Table  maintenance generator ,
    It seems to me lock object also adjusted( I am able to see the newly converted primary key fields in lock object( in se11 ) ).
    Does the lock object automatically adjusts ????
    If lock object adjusts automatically --> what about the function modules ENQUEUE_ztable DEQUEUE_ztable ? these function modules also gets adjusted ?
    do I need to check the associated lock object impact ?
    How can I check ?

    Hi,
    No need to delete the Lock object. Just <b>remove</b> the Table which you modified from Lock object & <b>add again</b>. You can add the lock Parameters manually. It will be drived automatically from Table key fields.
    You no need to delete the lock object.
    Raja T
    Message was edited by:
            Raja T

  • Where do I use These lock object FM's (Enqueue & D? and How do I use them?

    I created lock object for user defined table (zconsist). The system automatically created 2 FM's (Enquiue & Dequeue).
    I created a new TCode and accessing this with mulitple users to do some updates and inserts in that above table.
    I used INSERT ZCONSIST statement in 5 places in my program (4 include programs).
    Where do I use These FM's? and How do I use them?
    I mean before inserting which FM I need to use? after immediately what fm used?.
    every insert statemnt before i need to use the respective fm? so 5 places i need to call the respective FM is it right?
    thank in advance.

    Hi Sekhar,
    Lock objects are use in SAP to avoid the inconsistancy at the time of data is being insert/change into database.
    SAP Provide three type of Lock objects.
    Read Lock(Shared Locked)
    protects read access to an object. The read lock allows other transactions read access but not write access to
    the locked area of the table
    Write Lock(exclusive lock)
    protects write access to an object. The write lock allows other transactions neither read nor write access to
    the locked area of the table.
    Enhanced write lock (exclusive lock without cumulating)
    works like a write lock except that the enhanced write lock also protects from further accesses from the
    same transaction.
    You can create a lock on a object of SAP thorugh transaction SE11 and enter any meaningful name start with EZ Example EZTEST_LOCK.
    Use: you can see in almost all transaction when you are open an object in Change mode SAP could not allow to any other user to open the same object in change mode.
    Example: in HR when we are enter a personal number in master data maintainance screen SAP can't allow to any other user to use same personal number for changes.
    Technicaly:
    When you create a lock object System automatically creat two function module.
    1. ENQUEUE_<Lockobject name>. to insert the object in a queue.
    2. DEQUEUE_<Lockobject name>. To remove the object is being queued through above FM.
    You have to use these function module in your program.
    check this link for example.
    http://help.sap.com/saphelp_nw04s/helpdata/en/cf/21eea5446011d189700000e8322d00/content.htm
    tables:vbak.
    call function 'ENQUEUE_EZLOCK3'
    exporting
    mode_vbak = 'E'
    mandt = sy-mandt
    vbeln = vbak-vbeln
    X_VBELN = ' '
    _SCOPE = '2'
    _WAIT = ' '
    _COLLECT = ' '
    EXCEPTIONS
    FOREIGN_LOCK = 1
    SYSTEM_FAILURE = 2
    OTHERS = 3
    if sy-subrc 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    endif.
    Normally ABAPers will create the Lock objects, because we know when to lock and how to lock and where to lock the Object then after completing our updations we unlock the Objects in the Tables
    http://help.sap.com/saphelp_nw04s/helpdata/en/cf/21eea5446011d189700000e8322d00/content.htm
    purpose: If multiple user try to access a database object, inconsistency may occer. To avoid that inconsistency and to let multiple user give the accessibility of the database objects the locking mechanism is used.
    Steps: first we create a loc object in se11 . Suppose for a table mara. It will create two functional module.:
    1. enque_lockobject
    1. deque_lockobject
    before updating any table first we lock the table by calling enque_lockobject fm and then after updating we release the lock by deque_lockobject.
    http://help.sap.com/saphelp_nw04/helpdata/en/cf/21eea5446011d189700000e8322d00/content.htm
    GO TO SE11
    Select the radio button "Lock object"..
    Give the name starts with EZ or EY..
    Example: EYTEST
    Press Create button..
    Give the short description..
    Example: Lock object for table ZTABLE..
    In the tables tab..Give the table name..
    Example: ZTABLE
    Save and generate..
    Your lock object is now created..You can see the LOCK MODULES..
    In the menu ..GOTO -> LOCK MODULES..There you can see the ENQUEUE and DEQUEUE function
    Lock objects:
    http://www.sap-img.com/abap/type-and-uses-of-lock-objects-in-sap.htm
    http://help.sap.com/saphelp_nw04s/helpdata/en/cf/21eea5446011d189700000e8322d00/content.htm
    Match Code Objects:
    http://help.sap.com/saphelp_nw2004s/helpdata/en/41/f6b237fec48c67e10000009b38f8cf/content.htm
    http://searchsap.techtarget.com/tip/0,289483,sid21_gci553386,00.html
    See this link:
    http://www.sap-img.com/abap/type-and-uses-of-lock-objects-in-sap.htm
    Check these links -
    lock objects
    Lock Objects
    Lock Objects
    kindly reward if found helpful.
    cheers,
    Hema.

  • Differeence between Lock object and enqueue_e_table

    Hi  ,
    what is diff between Lock object and enque_e_table.  Where to use enqueue_e_table and where to use lock object.
    I think with a lock object i can lock more than one table (passing tables  in secondary table). Please correct me.

    A lock object does not really "lock a table" though most of lock objects refer to a database table.
    I explain:
    The principle is that when 2 programs lock at the same time with the same lock object, only the first will succeed.
    If you have a program which does not use the lock, it may update the database table without any problem.
    All programs which update a table have to use the same lock object. Note that users are always able to update this table via SM30 as they don't know the lock object to be used.
    enqueue_xxxx is the name of the generated function module used to lock the xxxx lock object. E_TABLE lock is ONLY used by SM30 if I remember well, so that to prevent one table from being updated via SM30 by 2 persons at the same time. But it is not related at all with programs which would also update this table.
    Edited by: Sandra Rossi on Mar 14, 2010 9:53 PM

  • Help in lock object

    HI All
    i am want to handle lock object for instance if i want to lock some object and it's already locked i want to do some loop on it for 5 times .
    1. i need to know if what i was doing is OK since this is my first time .
    2. what should i use i parameter wait can it help me ?
    Kind Regards
    Chris
    iv_try_x_times = 5. "this value on the method signature
      DO iv_try_x_times TIMES.
        lv_count = lv_count + 1.
        CALL FUNCTION ENQUEUE_USR_DATA
        EXPORTING
        mandt = sy-mandt
        userid = mv_userid
        x_for_user            = iv_is_exact 
        _wait                 = iv_is_wait
      EXCEPTIONS
        foreign_lock = 1
        system_failure = 2
        OTHERS = 3.
        IF sy-subrc = 0.
          RETURN.
        ENDIF.
        IF lv_count < iv_try_x_times.
          WAIT UP TO 1 SECONDS.
        ENDIF.
      ENDDO

    Hi Chris,
    Such a code piece might help you;
    data: is_locked type c,
             lv_counter type i.
    is_locked = ''.
    lv_counter = 0.
    while is_locked = '' and lv_counter < 5.
      lv_counter = lv_counter + 1.
        CALL FUNCTION ENQUEUE_USR_DATA
        EXPORTING
        mandt = sy-mandt
        userid = mv_userid
        x_for_user            = iv_is_exact 
        _wait                 = iv_is_wait
      EXCEPTIONS
        foreign_lock = 1
        system_failure = 2
        OTHERS = 3.
        IF sy-subrc = 0.
          is_locked = 'X'.
       else.
          wait  up to 1 seconds.
       endif.
    endwhile.
    Regards;
    Ozcan.

  • Enqueue: Elem.lock 0 contains unpermitted lock mode . lock object EZBEV_BO

    Hello Guru's,
    we have a unusual problem in the syslog of our ERP System.
    Enqueue: Elem.lock 0 contains unpermitted lock mode . lock object EZBEV_BO
    We can't found any note or forum entry to solve this.
    We checked SAP Notes: 1324099, 891372, 606425, 447242, 1260601 and searched in the forum, but nothing helpful found.
    System Data:
    ERP 6.0 / NW7.01 with EHP4
    SAP Kernel :  701_REL
    created on  :  Jan 18 2010 21:47:07
    Kernel Patch number : 77
    Source ID  :  0.077
    DBSL Patch No. : 075
    Database
    ORACLE 10.2.0.2
    Operating System
    AIX 5.3
    Can someone help?
    regards
    Chris

    developer error

  • Lock object for Purchase Order

    Dear Experts.
    I am searching the function module "ENQUEUE_   " , which is for locking & Unlocking
    the Purchase order(ekko-ebeln).
    Please help me.
    Thanks in advance,
    Regards,
    Rahul.

    Hi,
    Use the Lock object EMEKKOE to Lock and Unloack the Purchase orders
    Use this FM to lock
    MM_ENQUEUE_DOCUMENT
    This is also used in the standard program. While enqueing,
    if there is any error (sy-subrc 0), then it means,
    that particular purchase order is already locked
    Use Fm DEQUEUE_ALL to release all lock at the end of report execution.
    Regards,
    Shamma
    Edited by: Shamma Firdous on Aug 20, 2009 10:22 AM

Maybe you are looking for