Best table lock suggested ??

hi,
i have a scenario as follows:
i am developing a custom transaction, dialog based, basically to perform add/modify/delete data from custom tables. Multiple users can login and try to work on the data, one can add records to the same table and another can modify teh records of the same table. So whats the best kind of table lock to be used ? and how to hande that ?
thks

Hi,
For Locking look at the below code
  DATA: l_v_locktab   TYPE tabname,
        l_v_funcname  TYPE rs38l_fnam,
        l_v_noobj     TYPE flag,
        l_v_garg      TYPE eqegraarg,
        l_i_enq       TYPE STANDARD TABLE OF seqg3.
  IF rb_upd = space.
    EXIT.
  ENDIF.
  l_v_locktab = fp_table.
  CASE l_v_locktab.
    WHEN 'LIPS'.
      l_v_locktab = 'LIKP'.
    WHEN 'VBAP'.
      l_v_locktab = 'VBAK'.
    WHEN 'VBRP'.
      l_v_locktab = 'VBRK'.
    WHEN 'PLPO'.
      l_v_locktab = 'PLKO'.
  ENDCASE.
* Search Lock objects for the table
  SELECT viewname FROM dd25l INTO v_lockobj
         UP TO 1 ROWS
         WHERE aggtype = 'E'
         AND   roottab = l_v_locktab.
  ENDSELECT.
  IF sy-subrc = 0.
    CONCATENATE 'ENQUEUE_' v_lockobj INTO l_v_funcname.
*   Check if the  Enqueue function is OK
    SELECT SINGLE funcname FROM tfdir INTO l_v_funcname
                  WHERE funcname = l_v_funcname.
    IF sy-subrc = 0.
      CALL FUNCTION l_v_funcname
*       EXPORTING
*         MANDT                = SY-MANDT
*         _SCOPE               = '2'
*         _WAIT                = ' '
*         _COLLECT             = ' '
       EXCEPTIONS
         foreign_lock         = 1
         system_failure       = 2
         OTHERS               = 3
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE 'I' NUMBER sy-msgno
                WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
        LEAVE LIST-PROCESSING.
      ENDIF.
    ELSE.
      CLEAR v_lockobj.
      l_v_noobj = 'X'.
    ENDIF.
  ELSE.
    CLEAR v_lockobj.
    l_v_noobj = 'X'.
  ENDIF.
*   If No lock object is found for the table, do a general check.
*   Read Locks
  IF l_v_noobj = 'X'.
    CALL FUNCTION 'ENQUEUE_READ'
     EXPORTING
        gname                       = fp_table
*       GARG                        = ' '
        guname                      = space
*       LOCAL                       = ' '
*     IMPORTING
*       NUMBER                      =
*       SUBRC                       =
      TABLES
        enq                         = l_i_enq
     EXCEPTIONS
       communication_failure       = 1
       system_failure              = 2
       OTHERS                      = 3
    IF l_i_enq[] IS NOT INITIAL.
      MESSAGE i023.
      LEAVE LIST-PROCESSING.
    ELSE.
      CONCATENATE fp_table '*' INTO l_v_garg.
      CALL FUNCTION 'ENQUEUE_READ'
       EXPORTING
          gname                       = 'RSTABLE'
          garg                        = l_v_garg
          guname                      = space
*         LOCAL                       = ' '
*       IMPORTING
*         NUMBER                      =
*         SUBRC                       =
        TABLES
          enq                         = l_i_enq
       EXCEPTIONS
         communication_failure       = 1
         system_failure              = 2
         OTHERS                      = 3.
      IF l_i_enq[] IS NOT INITIAL.
        MESSAGE i023.
        LEAVE LIST-PROCESSING.
      ENDIF.
    ENDIF.
* if No Lock exists. Do a common lock
    CALL FUNCTION 'ENQUEUE_E_TABLE'
     EXPORTING
*      MODE_RSTABLE         = 'E'
       tabname              = fp_table
*      VARKEY               =
*      X_TABNAME            = ' '
*      X_VARKEY             = ' '
*      _SCOPE               = '2'
*      _WAIT                = ' '
*      _COLLECT             = ' '
     EXCEPTIONS
       foreign_lock         = 1
       system_failure       = 2
       OTHERS               = 3
    IF sy-subrc <> 0.
      MESSAGE ID sy-msgid TYPE 'I' NUMBER sy-msgno
              WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      LEAVE LIST-PROCESSING.
    ENDIF.
  ENDIF.
for unlocking
  DATA: l_v_funcname  TYPE rs38l_fnam.
  IF v_lockobj NE space.
*   if Lock Object is available
    CONCATENATE 'DEQUEUE_' v_lockobj INTO l_v_funcname.
*   Check if the  Dequeue function is OK
    SELECT SINGLE funcname FROM tfdir INTO l_v_funcname
                  WHERE funcname = l_v_funcname.
    IF sy-subrc = 0.
      CALL FUNCTION l_v_funcname.
    ENDIF.
  ELSE.
*  Do a common Unlock
    CALL FUNCTION 'DEQUEUE_E_TABLE'
     EXPORTING
*     MODE_RSTABLE       = 'E'
      tabname            = fp_table
*     VARKEY             =
*     X_TABNAME          = ' '
*     X_VARKEY           = ' '
*     _SCOPE             = '3'
*     _SYNCHRON          = ' '
*     _COLLECT           = ' '
  ENDIF.
Shreekant

Similar Messages

  • Custom Scenario requiring table Lock - Please Suggest

    Hi ,
    Custom usecase :
    There exist a table with following column :
    FileName, LastUpdatedBy, ApprovedBy, DisapprovedBy, LogicallyDeleted, FileDescription, Col2
    Primary Key - ( FileName, LastUpdatedBy,ApprovedBy)
    Constraint : FileName,lastUpdatedBy,ApprovedBy cannot be null. Default values for LastUpdatedBy, ApprovedBy, DisapprovedBy is NONE, and LogicallyDeleted is N.
    Note : User should not be allowed to create more that two records for same fileName.
    Edit functionality required on UI : On editing a record, a copy of the row should be created with same fileName , LastUpdatedBy with userId of logged in User.
    How should I restrict user from doing the following :
    Two users open the UI. Selected same record to edit. At time of commit only record for one should get commited, while for other it should not happen as 2 records gets created for same file name as soon as commit is done for one user.
    Do i need to have table lock, then count row with a particular file name and if count >2 then commit else throw some exception. And if this is needs to be done than which method should be overridden to do that.
    Thanks,
    Rajdeep

    Hi
    To Shay : ( You can define a new method validation at the entity level to do the check for you. http://docs.oracle.com/cd/E16162_01/web.1112/e16182/bcvalidation.htm#CACGFEDC )
    From my post : - Where should that logic can be implemented in ADF BC and what logic ( anything different from what I mentioned in post ) ?
    If I am going to write validation in custom method at entity level, I think it is not handling the scenario properly. For example : Query for Count on fileName records is fired in validator method for two entities before the commit is happening for any of the two.
    Also What logic : do you agree with table lock logic requirement here ?
    To Santosh,
    I think you didn't got the scenario. It does not talk about two user doing normal edit on same record. Notice two facts mentioned in post :
    1. When a user selects a record to edit... he is not actually editing it. We create a copy of the row ( with FileName , LastUpdatedBy,ApprovedBy,LogicallyDeleted as readOnly and prepopulated with sameFileName as original record, UserId in LastUpdatedBy, NONE defaults for Approved by and Disapproved By , N default for LogicallyDeleted) launched in popup. Popup has two buttons ... save and cancel. On cancel we rollback transaction ( i.e. deletes the newly created copy ) and Save ... eventually commits the row.
    2. Not more two records should get created in table for same fileName. So two users trying to edit same record will eventually try to create the 3 records in database table. It should fail for 3rd one...
    What logic should be written ... Does it really need the table lock ? Etc
    Thanks,
    Rajdeep

  • Multiple parallel loads into one table with TABLE LOCK option

    Hi everyone:
    We have several SSIS packages where each package has the basic design of having one sequence container. Inside each sequence container can be anywhere from 2 - 9 data flow tasks where for each data is selected from a different table but all 2-9 tasks do
    an OLEDB fast load (with table lock option checked) into the same single destination table.
    The number of rows were pulling from the various sources might be anywhere from 5 up to 100,000.
    Right now this doesn't seem to be causing any issues, but I wanted to check to see if this set up (since we're doing a review) could potentially cause problems down the road?
    We seem to think that each parallel task will acquire its data as normal, and just won't be able to insert until one of the other parallel tasks completes its fast load. To us, that's no big deal as we're at least able to acquire the data in parallel.
    What are everyone's thoughts?
    Thanks!

    >>>We seem to think that each parallel task will acquire its data as normal, and just won't be able to insert
    until one >>>of the other parallel tasks completes its fast load. 
    That is correct observation.
    Best Regards,Uri Dimant SQL Server MVP,
    http://sqlblog.com/blogs/uri_dimant/
    MS SQL optimization: MS SQL Development and Optimization
    MS SQL Consulting:
    Large scale of database and data cleansing
    Remote DBA Services:
    Improves MS SQL Database Performance
    SQL Server Integration Services:
    Business Intelligence

  • Table Lock DB2

    Hello All,
    Just wanted some advice, here is my situation.
    I have a message driven bean which i want to ensure i only receive once.
    So i am storing the MDB id's in a DB2 Database.
    (simple table that just stores MDB id's plus some other mdb data)
    I would like to do a table lock to keep MDB reading/inserting consistency. In my transaction I would be.
    check if the id is there already and an insert if its not.
    I think I can use a select for update in DB2 but i have also been reading about setting isolation type of TRANSACTION_SERIALIZABLE. Which would be the best approach?

    also just found another DB2 SQL statment LOCK TABLE not sure if this is another good soultion.

  • Display only for table locks

    Is there a way to set up the table locks in a display only format(other than sm12).

    SM12 calls function ENQUEUE_READ, which in turn calls ENQUE_READ2, which in turn moves down below the ABAP surface into the sea of C when calling the kernel function C_ENQUEUE. Best you can do is probably to build something around the two first functions, if you manage to decode the raw data obtained by the functions. It shouldn't be too difficult; SM12 is fairly straightforward and creating a display program should be feasible.
    Unfortunately, even ST05 doesn't yield a result, so it seems (to me at least) that the enqueued entries (locks) reside on the server level, outside of the realm we can reach using SQL...
    Regards,
    Trond

  • Releasing table locks when user closes browser

    Hi, I've read the blogs and tried some of the code that people have suggested but it just never seems to work.  I have locked table entries belonging to a stateful 2003 BSP.  The user closes the browser by means of the 'X' and the table locks remain.  I have table lock releases in the 'OnDestroy' event but that never seems to occur.  I have tried inserting JavaScript to capture the closing of the window but either it captures every other event or it gets confused when navigating to another page.  I have the redirect examples however they all seem to be part of a proper logoff procedure, rather than the cowboy approach of just shutting down the browser.  There must be a simple procedure out there to do this.  Is there a complete example somewhere?
    Any help will be appreciated,
    Kevin

    Hi Raja, ok I discovered why it isn't working and it really is quite obvious.  The browser that it's being tested on has a Google toolbar installed. Among other things this toolbar allows users to block the display of popups.  If this is selected the script will not run properly as it needs the alert to allow the server side to run.  This is going to be frustrating because while most of the user's desktop is managed by the corporation they still have the ability to add toolbars to their browsers and configure them, and I'm sure most people will select the popup blocker. 
    Kevin

  • NRIV Table Lock

    Hi,
    I need a help on how to get NRIV table lock released ?
    The users create Claims using portal as well R/3.
    While creating claim, a number will be generated.
    Problem is :
    When users create claim , one user gets system hang and other are not able to create claim.
    In DB01 we can see a lock on NRIV table HOLD status and DBTABLOG WAIT status.
    Once this lock is released, the users are able to create claim as usual.
    Program logic:
    Thre is a number range used for Claim number.
    This object is locked and unlocked by FM 'NUMBER_RANGE_ENQUEUE' and 'NUMBER_RANGE_DEQUEUE'.
    To generate number  : NUMBER_GET_NEXT is used.
    This object is not buffered.
    While Header table Enqueue ,  Lock mode is 'E'.
    Suggestion i gave  : To increase the buffer size. we can give No of number in buffer as 10 - 20.
    But if so, how will the GAPS in the number generated would be. So user is afraid on this gap.
    Please help me to get rid of this NRIV table lock.
    Regards,
    Priya

    Check
    the note 399207

  • MacBook Pro: Best Laptop Lock?

    Greetings,
    I'm looking to the buy the best laptop lock for my MacBook Pro. I was taking a look at the: "Kensington Slim Kevlar MicroSaver Lock - Graphite" (listed online at the Apple Store).
    Any suggestions?
    Thanks.

    Hi,
    I bought this one from apple store, and I am really happy with it.
    Greetings,
    I'm looking to the buy the best laptop lock for my
    MacBook Pro. I was taking a look at the: "Kensington
    Slim Kevlar MicroSaver Lock - Graphite" (listed
    online at the Apple Store).
    Any suggestions?
    Thanks.
    MacBook Pro 2.16,ibook g4 1.33, Compaq evo n800v p4-M 2.0   Mac OS X (10.4.7)   and Linux on my compaq

  • Deactivate table locks for SAP courses

    Hello,
    when visiting SAP courses in Walldorf, I observed that it was possible that all participants where able to maintain the same customizing table without getting informed that the table is locked.
    How can this behaviour be achived? Usually only one user is able to maintain a table at a time, however, especially for SAP courses it would be great to deactivate this.
    Any ideas?
    Thanks & regards
    Wolfgang

    Hello all,
    if this is still interesting for someone:
    I found this page http://****************/Tutorials/ABAP/Lock/Page1.htm where they explain how to create a special report that will call the customizing view for a specific table in a different mode.
    The report will delete the general table lock and create row-based locks (based on key fields) instead, allowing at least several users to work with the same table - as long as they edit entries that have different key fields.
    I haven't tried it yet, but it looks promising...
    Best regards
    Tobias

  • Share Table Locks (S)

    Hi All,
    I'm using version - Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Prod
    Oracle doc(relase 10.2) - A share table lock is acquired automatically for the table specified in the following statement:
    LOCK TABLE table IN SHARE MODE;
    Permitted Operations: A share table lock held by a transaction allows other transactions only to query the table, to lock specific rows with SELECT ... FOR UPDATE, or to run LOCK TABLE ... IN SHARE MODE statements successfully.
    --It means...if table is locked in share mode ,than other transaction can fire <select * from table_name where ... for update> statment.
    the way I have tried...
    Scott_1> lock table t_chk in share mode;
    scott_> select * from t_chk where a = 10 for update; <this stmt waits for scott_1 to fire rollback or commit>
    than Pls let me know what is meaning of --<to lock specific rows with SELECT ... FOR UPDATE> in above explation.
    source -
    http://download.oracle.com/docs/cd/B19306_01/server.102/b14220/consist.htm#sthref1939

    Hi,
    if I understand what you are asking...
    Lock for update tells the database that you have locked your database set for UPDATE purposes.
    So if you attempt to do this with a data set that it is currently being updated then your code fails when it tries to reserve and no updates are done.
    If you do it and some tries to update the same data whilst you have it locked for update, then there update will be pending the completion of yours, and will not be allowed to happen until after you finish.
    If someone else attempts to Lock for Update whilst you have your lock for update then there code will fail and no updates are done by them...
    As for SELECT - as SQL updates are either committed (have happened) or not - then the user will always get a read consistent result, but your locks never prevent their snapshots allowing normal query behaviour.
    Make sense??
    regards,
    Robert.

  • Time out parameter to avoid Table locking

    Hi,
    I am looking at any configurable parameter if any for setting the time out parameter to avoid Table locking.Now what's happening is : If i run select ...for update from one session,oracle is applying a lock till i do a commit.And if i run the same query from another session,it takes unspecified time without returning any error.Using the query with NOWAIT options does not serve my purpose.
    Any help in this regard is appreciated
    Thanks
    Sam

    Are you looking for a way to time out the original query, or are you looking for a way for the second query to wait for some time and then abort if it is unable to lock the row(s)?
    Justin
    Distributed Database Consulting, Inc.
    www.ddbcinc.com

  • Best Table to use in form for Column Comments maintenance

    Hi,
    I want to create an Oracle Form to maintain Comments for each column in all of user_tables. eg. Order Entry, Customer.
    What would be the best table to use for this excercise. All of our developers
    will need this form to be used each time a new table is created (We don't, or never have, included comments in table creation scripts, although I do apreciate that it would be the better option) and to "catch up on comment maintenance".
    So we need a form to maintain such info. I am just wondering what would be the most appropriate table for this job.
    Thanks people.
    N

    Sorry, I don't really follow Andrews answer, even though he normally gives good advice.
    USER/ALL_TABLES are views of the data dictionary, not tables where you can choose to store something.
    Oracle supports commenting via the COMMENT command, and the results of doing so are visible in data dictionary views ALL_TAB_COMMENTS and ALL_COL_COMMENTS. The comment command has existed for ever (well it was in V5 anyway) and I have always found it surprising that Oracle have never (to the best of my knowledge)included support for it in their tools. Comments are hardly likely to be maintained properly if people need to write sql to see them. I am glad to see that at least TOAD does support the feature.

  • What's the Best Securirty Lock for Powerbook?

    I just got the new 17" PowerBook and am looking to buy the best security lock cable for it. I have read some posts before indicating some locks damaged their PowerBooks. I would appreciate your comments on your experiences and your recommendations. Thanks.

    George,
    There are a variety of locks out there so you can pretty much pick any one. Important to note is whether you want a combo lock or one with a key. For me I use a combo lock since it's one less key I have to carry on an already crowded key chain. Most locks come with plastic washers of various thicknesses. Do not discard these. Basically they are included because even though all lock slots are standard kensington, case designs vary. Some are thicker than others. The washers take up the slack in the lock so it mounts flush to the case. For the PB it provides a dual purpose as it keeps the metal lock from scratching the side of the PB case. I forgot to use mine the first time and I have a small half-circle scratch where the lock rubbed against the side of the PB case..'sigh', causing yet another blemish on my otherwise pristine PB. Oddly enough the only other blemish was also caused by my lock. I accidentally dropped it while standing over my PB and now there is this little pinhead sized gouge to the right of the trackpad near the SuperDrive slot.
    Jrsy

  • Configuring profile parameter for a table lock object

    Hi Experts-
      I want to set the 'wait time' (_WAIT) parameter as a profile parameter for a table lock object.
      I have created a lock object on a ZTable. I lock and unlock this object in exclusive non-cumulative mode through the enqueue and dequeue lock object function modules. These generated FMs are invoked via my custom function module.
      My function module will run in the background as a scheduled task in R/3. I execute the Enqueue FM at the start of the FM and keep the table locked until the last step finishes in my FM and then I Dequeue it. I want to have the processing wait and retry the Enqueuring FM at set intervals in case the one run doesn't finish entirely and a new run of this same job kicks off.
    Thank you,
    - Vik.

    Set the wait parameter = 'X'.  These means that if it encounters a lock, then it will wait a certain time for the lock to be released.  This certain time is a system value set by your basis team.  I don't imagine it being a very long time.
      CALL FUNCTION 'ENQUEUE_EZPIPHYINVREF'
           EXPORTING
                MODE_ZPIPHYINVREF = 'E'
                MANDT             = SY-MANDT
                _WAIT             = 'X'.
    Regards,
    Rich Heilman

  • How to release table locks?

    I was running Data Services (4.0 SP2) to load data into Hana (1.0 SP2 patch 20) using the Bulk load option. Apparently, the DS process hung and now the table I was writing to is locked although the DS Job is dead. How do you release the table lock without restarting Hana DB?

    Hello Sachin,
    you could try these statements. The first one will cancel the currently executed operation, the second one will disconnect the idle session:
    ALTER SYSTEM CANCEL SESSION session_id;
    ALTER SYSTEM DISCONNECT SESSION session_id;
    Regards,
    Mark

Maybe you are looking for

  • Website software for MAC and PC?

    HI all, I am about to build my first website. Can anyone tell me if there is some software which i can use on my MAC to build and upload a website, but which can be viewed and edited by another person on a PC. I was hoping to use Freeway express to b

  • PDF Printing  APEX 3.2.1  (APACHE FOP) which OC4J version  for Oracle 11g?

    I am using APEX 3.2.1 on Oracle 11.g (under windows XP) I want to test PDF printing (in advanced turorial) with standard config ( APACHE FOP no Oracle BI publisher). When I look oracle doc : http://www.oracle.com/technology/products/database/applicat

  • Communications problem with radio link

    A customer has a network composed from a LAN shared-media (with hub 8-ports), a router linked to three modems wich link to three 9.6 kbps radio links. These radio links have linked to another three modems and PC remotes. The problem is that in LAN si

  • Starting dialog after workflow starts

    hi there, i have a user request and i don''t know how to handle this. i have tried to do it another way, but for our users this is not acceptable. the users enter absences in HR for other collegues (illness, ......). Each of the entered or changed or

  • Internet security applications for XP - which one?

    I'm about to do boot camp and add XP. Once I've turn the machine into a windows PC I'll need to have some anti-virus, firewall and all that. Don't trust XP's own offering. Which is the most compatible internet security application when using Boot Cam