Query on sap locks(ENQUEUE/DEQUEUE)

Hi All,
should the sap locks ENQUEUE/DEQUEUE need to be used  for all the updation/insertion  of records ino the table?
Please confirm.Should this locking technique be used even for insertion of records into the table?
Regards,
Pra.

Hi,
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.
Hope this will give a basic idea.

Similar Messages

  • Query about SAP locks /enqueue objects

    I have created an lock object for a bespoke table which has 5 key fields.  For arguments sake let's call them
    WERKS QMGRP QMCOD OTGRP OTEIL.
    The problem I have is the following:
    User 1 has a house profile that can access the following data:
    WERKS QMGRP QMCOD OTGRP OTEIL
    9026  HOUSE CUST
    User 2  has a functional profile which gives them access to the following:
    WERKS QMGRP QMCOD OTGRP OTEIL
    9026  HOUSE CUST 
    9026  HOUSE CUST   CS    C001
    9026  HOUSE CUST   CS    C002
    I am building a front-end to the table to enable the users to change data associated with these keys.  My problem is the following.  If User 2 locks the entries,(s)he has access to first, the user 1 entry will be locked to changes,  which is correct.  If, however, user 1 locks its entry first, <b>all</b> of user 2's entries are locked even though only the first entry is allowed to be accessed by both.  I think this is happening because the SAP lock object does not recognise '   ' '    ' as a separate value to 'CS' 'C001'.  It thinks because 9026 HOUSE CUST '   ' '    ' is locked, then the other entries should be locked because they share 9026 HOUSE CUST from the key, even though there are other values in the key following 9026 HOUSE CUST.
    What I want is if user 1 locks its entry first, then only the entry that matches the key  totally for user 2 is locked, leaving the other 2 entries to which user 2 has access free to be edited.
    Is there a way I can get the SAP lock object to recognise this eitehr by changing the enqueue function module or by the way I cal the enqueue object or not?
    Any help would be appreciated.
    Hope this makes sense
    Larissa

    Hi Larissa,
    As far as I know, You cannot change generated enqueue function module. The other way as i think might work would be to create a new FM and do manipulation (for space to be changed as some other value) before calling this generated Enqueue FM.
    Hope this helps.
    Regards,
    Vicky
    PS: Award points if helpful

  • SAP Lock (Enqueue Lock)

    Hi there,
    I have used SAP Enqueue and Dequeue Lock in my program. However, it does not seems to work. Do I need to have a specific authorisation in order to be able to perform Enqueuing n Dequeuing?
    In addition, when i perform CALL FUNCTION 'ENQUEUE_XXXXXX', what does the return code, sy-subrc = 4 signifies?
    Thank You.

    Use transaction SM12 to see if you already have any locks.  Also worth checking the data you are trying to lock is actually on your database table.
    Gareth.

  • 2515 Locking FMs to Enqueue/Dequeue/ Which one to use?

    I know this question is redundant, and has been responded to a million times....all differently. However, being their are 2,515 function modules to choose from, what are the best choices for locking and unlocking a custom database table?
    And, why are their 2,515 of them?
    I take that back....many many more!
        Thank-You
    Edited by: Tom Matys on Sep 23, 2011 12:15 PM

    Hi
    I think the best way is to create a new lock object for every custom tables.
    Every table should have an own lock object (so own fms to Enqueue/Dequeue) because it makes sure the same lock object is not used for another table at the same time.
    If the same lock object is used for many tables it can risk to find a certain record locked although nobody locks it really.
    Max

  • Enqueue/Dequeue - Locking/Unlocking object

    Hi all,
    Please help me working with this enqueue/dequeue command. What I'm trying to do is to lock a Service Order. My requirement is to do a BDC for the Service Order Settlement Rule. So after hitting SAVE, a secondary process will be kicked off to perform my BDC for the same order. Now what Im doubting is that what if user re-enter the same Service Order again so quick. So my BDC program will not be performed immediately since it will be locked by the usser.
    So my idea is to lock it first while my BDC program is still running. Any help please? Thanks.

    Nope. Just 1 BDC -on my 2nd program only. Or to make it simple, I have modified ZXWOCU07 (IWO10009) to perform/kick off a call function( this is being triggered after hitting on SAVE). And this FM contains my checking if SO is now open for change then do the do the BDC.
    What I'm thinking is to lock first the SO  to block any user from accessing that SO, so it will do the BDC first. But I'm not yet familiar with the locking/unlocking of objects. Please help me on how to use enqueue or locking object.

  • Enqueue/Dequeue

    Hi,
    There are 2 reports accessing 1 table. I am facing the runtime error with description - "The database system detected a deadlock and avoided it by rolling back your transaction.u201D
    Have come across implementing the ENQUEUE and DEQUEUE concept on the table. Please clarify the below queries:
    1.Is the above error occuring beacuse the two reports are accessing the table at the same time?
    2.Implementing EN/DEQUEUE will solve the problem?
    3.If first report is writing the data to table at 12pm(after locking the table), and the second report trying to access the table at 12:10pm to write the data, will this wait in some queue and write the data after the first report releases the table lock?
    Regards,
    Rajkamal

    Hello Raj,
    You should understand the difference between Database Locks & SAP locks.
    The database system detected a deadlock and avoided it by rolling back your transaction
    1.Is the above error occuring beacuse the two reports are accessing the table at the same time?
    Initial look at the statement suggests that this is because of Database Lock collision. You need to check if both the programs were trying to write (INSERT/UPDATE/MODIFY/DELETE) the same data to the DB table.
    2. Implementing EN/DEQUEUE will solve the problem?
    It should. But make sure you don't lock the entire table, try to lock only the individual records which are being processed(This is a good coding practice, of course you can override it depending on your requirement).
    3.If first report is writing the data to table at 12pm(after locking the table), and the second report trying to access the table at 12:10pm to write the data, will this wait in some queue and write the data after the first report releases the table lock?
    No, afiak there is no such queue. Alternatively you can put the lock in a iteration(viz., DO loop, WHILE loop) & check when the locks are released.
    Hope i'm clear.
    BR,
    Suhas

  • Issue with Enqueue / Dequeue

    We are working on a scenario where data is got into SAP through Web methods to create Sales orders.
    If we were to use Enqueue / Dequeue function while doing this would the web methods connection hold till the process is complete or would this time out in the middle?
    Is there any time out period for the connection with web methods, and if so how can it can be reset to an alternate value

    Hi,
    in ITS if you click on object, you can see the parmaters like
    ~TRANSACTION
    <b>~TIMEOUT</b>
    give more time for Time out parameter, that should solve the problem.
    Regards
    Vijay D T T.

  • Finding Enqueue/Dequeue functions

    Hi,
    Is there an easy way to find the enqueue/dequeue lock functions for a specific table?
    I tried to find the enqueue/dequeue functions for table LIKP. It took me a while to find it, but it turns out the name is ENQUEUE_EVVBLKE.
    You'd think that the table name would be incorporated into the function name to make it easy to find?!
    Does anyone have a suggestion?
    Thx.
    Andy

    Yes bro most of the times the table or field names would be in the Function module name.
    Raghav

  • Material Enqueue & Dequeue

    I hav designed a new application for store i wish to enqueue & dequeue  materials which store persons are using.
    So how can this be done.Please guide once i open any material in my applcation its locked untill i come out my application.I wishto unclock as my processing is over.
    Pls guide whch FM to use.

    hi,
    Create a lock object from SE11 by giving the name
    lock object : ezlock_material.
    call the function module enqueu_ezlock  in  th loop to which to all the materials to lock.
    to lock the material
    call the function module dequeu_ezlock  in  th unloop to which to all the materials to unlock.
    to unlock the material.
    Regards,
    Madhavi

  • What is Enqueue Work process in SAP ? Enqueue Process in Oracle ?

    Hello Nation,
    I am new to SAP BASIS ,When i was learning the sap basis architecture i came across a doubt that
    What is the work of SAP ENQUEUE ?
    What is ORACLE ENQUEUE?
    Why there is TWO ENQUEUE ?
    What is the difference between SAP ENQUEUE and ORACLE ENQUEUE ?
    Since i am fresher i couldn't differentiate use of both the enqueue process,awaiting
    Thanks in advance ,
    -Mohamed Naveen  

    please read this and in case you still have question.. ask.
    Relationship Between SAP Locks and Database Locks - The SAP Lock Concept (BC-CST-EQ) - SAP Library
    Enqueue Workprocess and database locking
    best regards
    ashish

  • Different between database lock and sap lock

    Hi All,
    What is different between database lock and sap lock why sap introduced locking mechanism.
    Thanks
    Santosh

    From a database perspective, every dialog step forms a physical and logical unit:
    the database transaction.. The database lock administration can only coordinate
    this type of database transaction. From an SAP point of view, however, this is
    not sufficient, because SAP transactions, which are formed from a sequence of
    logically related work steps that are consistent in business terms, are generally
    made up of several dialog steps. SAP systems need to have their own lock
    management. This is implemented using the enqueue work process. This also
    ensures that the platform-independence of the lock management is maintained.

  • Intenal error in SAP lock management system

    Hi All,
    I got an error like this:
    "An internal error was found in SAP lock management system when attempting to lock an object by calling an ENQUEUE functional module".
    Can you provide me a solution as soon as possible..
    Thanks in advance,
    Sreepathi

    Hi Sreepathi,
    Usually this happen when the enque process is no longer accesible. I will schedule a system and db restart.
    Regards
    Juan
    Please reward with points if helpful

  • Re: what is difference between sap locking and database locking

    hi,
        what is difference between sap locking and database locking. Iam locked the table mara by using lock objects.
    But iam unable to unlock the mara table. I give u the coding. Please check it.
    REPORT zlock .
    CALL FUNCTION 'ENQUEUE_EZTEST3'
    EXPORTING
       MODE_MARA            = 'S'
       MANDT                = SY-MANDT
       MATNR                = 'SOU-1'.
    call transaction 'MM02'.
    CALL FUNCTION 'DEQUEUE_EZTEST3'
         EXPORTING
              mode_mara = 'E'
              mandt     = sy-mandt
              matnr     = 'SOU-1'.
    IF sy-subrc = 0.
      WRITE: 'IT IS unlocked'.
    ENDIF.

    Hi Paluri
    Here is the difference between SAP locks and Database locks, i will try to find the solution to your code.
    Regards
    Ashish
    Database Locks: The database system automatically sets database locks when it receives change statements (INSERT, UPDATE, MODIFY, DELETE) from a program. Database locks are physical locks on the database entries affected by these statements. You can only set a lock for an existing database entry, since the lock mechanism uses a lock flag in the entry. These flags are automatically deleted in each database commit. This means that database locks can never be set for longer than a single database LUW; in other words, a single dialog step in an R/3 application program.
    Physical locks in the database system are therefore insufficient for the requirements of an R/3 transaction. Locks in the R/3 System must remain set for the duration of a whole SAP LUW, that is, over several dialog steps. They must also be capable of being handled by different work processes and even different application servers. Consequently, each lock must apply on all servers in that R/3 System.
    SAP Locks:
    To complement the SAP LUW concept, in which bundled database changes are made in a single database LUW, the R/3 System also contains a lock mechanism, fully independent of database locks, that allows you to set a lock that spans several dialog steps. These locks are known as SAP locks.
    The SAP lock concept is based on lock objects. Lock objects allow you to set an SAP lock for an entire application object. An application object consists of one or more entries in a database table, or entries from more than one database table that are linked using foreign key relationships.
    Before you can set an SAP lock in an ABAP program, you must first create a lock object in the ABAP Dictionary.

  • How to write a SQL query in SAP B1 2007 B with input parameters?

    How to write a SQL query in SAP B1 2007 B with input parameters, on execution of which will ask for some input value from the user and the values will be selected from a list such as item list?

    The syntax like
    SELECT * FROM OITM T0 WHERE T0.ItemCode = '[%0\]'
    Thanks,
    Gordon

  • Error in while running a query in SAP B1

    Hi All,
    I am creating one Q-PLD so i have to run the following query. Query is working fine in SQL Server
    But while running with SAP B1 showing error 'Cant convert into varchar to small int'
    Query is
    Select (select M1.[GroupName] from OCRG M1 where M1.[GroupCode] = T2.[GroupCode]) As 'State',
    T0.[CardCode] AS 'Customer Code',T0.[CardName] AS 'Customer Name',T4.[U_SchNo] As 'Scheme Ref No',
    T1.[U_Itmgrp] AS 'Item Group',T1.[U_TAdvAmt] AS 'Actual Adv',T0.[DocDate] As 'Doc Date',
    T0.[DocNum] AS 'Invoice No.',T1.[U_QtyKgs] AS 'Qty In KG',T1.[U_CAdvRate] AS 'Advance Rate',
    T1.[U_DedAdvA] AS 'Actual Adv. Adj.',T1.[U_BalAdvA]- T1.[U_DedAdvA] As 'Balance'
    from [dbo].[OINV] T0  INNER JOIN [dbo].[INV1] T1 ON T0.DocEntry = T1.DocEntry
    INNER JOIN [dbo].[OCRD] T2 ON T0.CardCode = T2.CardCode
    INNER JOIN [dbo].[OCRG] T3 ON T2.GroupCode = T3.GroupCode
    LEFT OUTER JOIN [dbo].[@CUSTAMT] T4 ON T0.[CardCode] = T4.[U_Custcode]
    And T1.[U_Itmgrp] = T4.[U_Itemgrp]
    Where T0.[DocDate] between '[%0]' And '[%1]' And
    T0.[CardCode] between '[%2]' And '[%3]'
    And T1.[U_Itmgrp]  between '[%4]'  And '[%5]'   ' This line i am getting error
         ' If i this line will remove error will disappear or i will pass parameter directly like 'ItemGrop1'
    And T3.[GroupName] between '[%6]' And '[%7]'
    By
    Firos C

    Hello Firos,
    Now, first I assume that the t1.[U_Itmgrp] refers to the [ItmsGrpCod] in the OITM.
    I have tested this simple query in SAP Business One (Query Generator) as your query uses user defined fields I do not have in any database here.
    If this is the case you need the number associated with the item group name. This is the 'ItmsGrpCod' and you can find it in table OITB, therefore I would suggest to add this table to the query and search for the ItmsGrpNam that is the one that appear in the Item Master Data. E.g.:
    SELECT T0.[ItemCode] FROM OITM T0  INNER JOIN OITB T1 ON T0.ItmsGrpCod = T1.ItmsGrpCod WHERE T1.[ItmsGrpNam] = 'server'
    If this is the wrong assumption please consider CAST, but in this case you would need something similar to this:
    CAST ([U_PriceKG.NUMBER ]AS NUMERIC(19,6))
    Hope this helps, but if it doesn't can you please tell me what kind of values you have in U_Itmgrp and if it is written by the user or there is a formatted search?
    Thank you for your information.
    Marcella Rivi
    SAP Business One Forums Team

Maybe you are looking for

  • ORA-03113: when using xmltransform

    After messing with xslt I ended up with ORA-03113. db version is 11.1.0.6 test is reproducable with the following case: SQL> with t as (select xmltype('<?xml version="1.0" encoding="UTF-8"?>   2   <ns1:ResourceAvailabilityNotification   3   xsi:schem

  • Computer cannot read iPod

    When I plug the iPod into the computer, it continues as normal to upload the iPod. However, after a couple of seconds of trying, my computer comes up with a message saying that the iPod update attempt has failed, and that it cannot read or send to th

  • Dock keyboard shortcut interfering with other programs

    hello, all; just presenting a problem I'm been running into recently: using option-apple-d (the 'Duplicate' function in Freehand MX) is overridden by a default function in the Finder, that which hides/shows the Dock. I do not need the latter function

  • Content Server Upgrade

    Hello, I have plan to upgrade content server from 6.30 to 6.40 but I can't find upgrade guide for this. only install guide exist. I think that I have to upgrade MaxDB first and then upgrade content server. right? and can I use upgrade master cd of ne

  • My ipad air2 screen is black and won't come on. I can hear siri but she says she cant work right now. What do I do?

    My ipad air2 screen is black and won't come on. I can hear siri but she says she cant work right now. What do I do?