Record level locking

Hi Experts,
          I want to lock a table as per ecord level locking . How to go for it?
          Actually the table is being updated with key records simultaneously through different processes.
Regards,
Jyoti Shankar

HI,
SAP provides you with the ability to restrict access to data while the table is being updated. This is fairly
simple to implement via the use of a lock object . Create the Lock Object in SE11 for that table, if that already exist then use that one..
Add the following code in-order to create the table lock. This function module must be called before any
update takes place. If a lock has already been taken out it will display the appropriate message.
  CALL FUNCTION 'ENQUEUE_EZ_ZTABLENAME'
      EXPORTING
           mode_ZTABLENAME = 'E'
           mandt              = sy-mandt
           KEYFIELD1           = "Value
           KEYFIELD2           = "Value
           KEYFIELD3           = "Value
*         X_KEYFIELD1            = ' '
*         X_KEYFIELD2            = ' '
*         X_KEYFIELD3            = ' '
*         _SCOPE             = '2'
*         _WAIT              = ' '
*         _COLLECT           = ' '
*   If exceptions are not used, message is displayed within FM
    EXCEPTIONS
         FOREIGN_LOCK       = 1
         SYSTEM_FAILURE     = 2
         OTHERS             = 3.
  IF sy-subrc <> 0.
*   Retrieve message displayed within Function Module
    message id     sy-msgid
              type   'I'
              number sy-msgno
              with   sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    EXIT.
  ENDIF.
The following code will remove the lock for the specific table entries.
CALL FUNCTION 'DEQUEUE_EZ_ZTABLENAME'
    EXPORTING
         MODE_ZTABLENAME = 'E'
         MANDT              = SY-MANDT
           mandt              = sy-mandt
           KEYFIELD1           = "Value
           KEYFIELD2           = "Value
           KEYFIELD3           = "Value
        X_KEYFIELD1            = ' '
        X_KEYFIELD2            = ' '
        X_KEYFIELD3            = ' '
        _SCOPE             = '3'
        _SYNCHRON          = ' '
        _COLLECT           = ' '
releasing the lock is mandatory,
See the link for more info.
http://help.sap.com/saphelp_nw2004s/helpdata/en/41/7af4c8a79e11d1950f0000e82de14a/content.htm
Regards
Sudheer.

Similar Messages

  • Record level lock on SAP ABAP table editing

    Hello All,
    I have a requirement wherein I need to give users ability to be able to update contents of a table. Currently, there are using maintenance view on the table for adding/editing contents of this table. However, this prevents other users from being able to enter the table and edit contents of other records within the table.
    Can anybody please guide me how do I go about giving record level edit lock on the table instead of entire table edit lock.
    Appreciate all responses.
    Thanks and Regards,
    Samta.

    Ok
    I  have had a request like yours, i.e the users could manage the same table in the same time.
    The standard behavior avoids it, because a lock of entire table is set.
    This was my solution:
    A) I've created a maintenance view for my table, and I set the attibute S (for subset) for all fields will be the key I want to lock.
    B) I've generated the maintenance table program for the view above.
    In this way if it try to manage the view by SM30, it'll be possible only to indicate the  values of the fields for the subset, so not all data of the table will be loaded, but only the records satisfying  the key.
    C) I've created a program to run SM30 for my view, using the fm VIEW_MAINTENANCE_CALL:
    .CALL FUNCTION 'VIEW_MAINTENANCE_CALL'
           EXPORTING
                action      = 'S'  "Display mode
                view_name   = <table name>
           TABLES
                dba_sellist = tb_sellist
           EXCEPTIONS
                OTHERS      = 14.
    As you can see above, the SM30 is always called for DISPLAY only, in this way no standard lock is set
    D) I've use the event 19 in order to change the mode and set my lock:
    DATA: BEGIN OF MY_LOCK,
              MANDT       TYPE ZPPTA019-MANDT,
              WERKS       TYPE ZPPTA019-WERKS,
              /TRILOG/SE  TYPE ZPPTA019-/TRILOG/SE,
              COD_MOD_TAG TYPE ZPPTA019-COD_MOD_TAG,
            END OF MY_LOCK.
      DATA: W_SEL_LIST TYPE VIMSELLIST.
      DATA: VARKEY TYPE RSTABLE-VARKEY.
      FIELD-SYMBOLS: <MY_KEY> TYPE ANY.
      LOOP AT DBA_SELLIST INTO W_SEL_LIST
        WHERE VIEWFIELD = 'WERKS'
          OR  VIEWFIELD = '/TRILOG/SE'
          OR  VIEWFIELD = 'COD_MOD_TAG'.
        ASSIGN COMPONENT W_SEL_LIST-VIEWFIELD
           OF STRUCTURE MY_LOCK TO <MY_KEY>.
        IF SY-SUBRC = 0.
          MOVE W_SEL_LIST-VALUE TO <MY_KEY>.
        ENDIF.
      ENDLOOP.
      IF SY-SUBRC = 0.
        IF NOT MY_LOCK IS INITIAL.
          MY_LOCK-MANDT = SY-MANDT.
          VARKEY = MY_LOCK.
          CALL FUNCTION 'ENQUEUE_E_TABLEE'
            EXPORTING
              MODE_RSTABLE   = 'E'
              TABNAME        = 'ZPPTA019'
              VARKEY         = VARKEY
            EXCEPTIONS
              FOREIGN_LOCK   = 1
              SYSTEM_FAILURE = 2
              OTHERS         = 3.
          IF SY-SUBRC <> 0.
            MESSAGE ID SY-MSGID TYPE 'S' NUMBER SY-MSGNO
                    WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
          ELSE.
            MAINT_MODE = VIEW_ACTION = 'U'.
          ENDIF.
        ENDIF.
      ENDIF.
      CLEAR OLD_019.
    I hope it can help you
    Max

  • Record Level Lock

    Hi,
    I have a scenerio in which if a user data is being edited no other user should be able to perform update on the record. We can handle that using select for update but the specific requirement is that as soon as the one goes to the edit screen for the user the lock should be obatined for the data.
    How can i handle the situation when:
    1. User closes the browser without save/exit or system shutdown.
    2. How will i use the same transaction object which has obtained the recorrd lock to update/rollback on save/exit operation.
    Hope i stated the requirement clearly.

    Usually, a program should use optomistic concurrency when dealing with records. For instance, if your database table has 1000 records, it is unlikely two users would be viewing and then updating the same record such that the first user's changes are over written by the second user's update. Using optomistic concurrency, you would read the record, let the user alter it, then put the originial unaltered record values in the 'where' clause of the update statement. This way, whey he updates, the sql statement cannot find the record (because of values in the 'where' clause) which means its been altered by someone else. You can then notify the end user that the record was updated while he was editing it. Then present to the user the record and have him try altering it again.
    You can read more on optomistic concurency at: http://msdn2.microsoft.com/en-us/library/aa0416cz(VS.71).aspx
    If you still wish to lock the record, I suppose you can put the connection object that is in your transaction in the session scope. When the operation normally completes (user doesnt close the browser), you can close the transaction and remove the connection from session scope so it can be garbage collected. If the user closes the browser, in the JSP page, put a destroy() method and in it, end the transaction and destroy the connection in session scope so it can be garbage collected. Because the JSP page is compiled into a servlet, the servlet will automatically call the destroy() method (read up on servlets to determined the correct signature for the destroy() method). Make sure you use try/catch/finally to ensure connections are closed.
    I don't know if the above will work as described, so you will have to try it out and verify it. I personnelly think you should avoid this approach.

  • In an SAP Table is to possible to perfrom lock at the record level?

    Hi All,
      In an SAP Table/Ztable is to possible to perfrom lock at the record level?
    Is it possible to increease the size of the sap table or z-table to insert more records.
    For example I want to insert 50000 records into a z-table and the size category I have given as 0 means which can hold some 15thousand records.
    then what abt the remaining recors?
    how can I inser tthem?
    do I need to increase the manually or it will be done automatically?
    Could any one please explain this?
    Thanks in Advance.
    Regards.
    Abhilash.

    hi,
    u can insert no of  records into table based on ur size category.
    check these.
    0                0   to         1,200
    1            1,200 to         4,900
    2            4,900 to        19,000
    3           19,000 to        78,000
    4           78,000 to       310,000
    5          310,000 to       620,000
    6          620,000 to    25,000,000
    to lock records check this data.
    Lock mode
    Defines how to synchronize table record access by several users.
    The following modes exist:
    Exclusive lock
    The locked data can be read or processed by one user only. A request for another exclusive lock or for a shared lock is rejected.
    Shared lock
    Several users can read the same data at the same time, but as soon as a user edits the data, a second user can no longer access this data. Requests for further shared locks are accepted, even if they are issued by different users, but exclusive locks are rejected.
    Exclusive but not cumulative lock
    Exclusive locks can be requested by the same transaction more than once and handled successively, but an exclusive but not cumulative lock can only be requested once by a given transaction. All other lock requests are rejected.
    reward points if hlpful.

  • Row Level Locking while inserting a record.

    It is a good practice to lock the whole table or do the row level locking while performing any DELETE / UPDATE / MODIFY actions on a database table. Is it necessary to do the same thing while inserting a record via INSERT statement?
    One point may arise if two  users are inserting same records at a same time....
    Well i am little bit confused here bcos if a record doen't exist in a table what is the point of locking it.
    Please help me.

    create a lock object using SE11 for that perticular table and include field names in Lock parameters. Then it will generate two FMs one for locking and another for unlocking.
    Call the lock FM before updating the table and pass that row key value(For fields which taken in lock parameters for creating lock objects) to the exporting parameters.
    Then do the updation.
    Reward if useful...................

  • Row level locks

    Hi All,
    Version - Oracle Database 10g Enterprise Edition Release 10.2.0.2.0
    I have a card's data in a table. Whenver a two different sessions/threads selects the data sometimes they get the same card.
    Now I need to lock the record. If Thred-1 selects then it will lock the first records and thread-2 must select the second record as the first record is locked by thread-1.
    I have written a piece of code , at first session it locks one record and when second session select it selects no records.
    I have takem MIN group function because I want the cards to be selected in order.
    Can you please tell where is my code went wrong or need some changes. Data and code is given below.
    SQL> SELECT * FROM crm_pps_cards_sz ORDER BY 1;
    CARD_NO          PIN  SERIAL_NUMBER DATE_CREATED DATE_MERGED DATE_ALLOCATED DATE_REGISTERED
    6338079966430591 9985 9950013661    12/06/2011                             
    6338079973369543 6858 9950013660    12/06/2011                             
    6338079978994154 7144 9950013655    12/06/2011                             
    6338079981471778 7631 9950013654    12/06/2011                             
    6338079986365041 7849 9950013657    12/06/2011                             
    SQL>
    Thread - 1
    Connected to Oracle Database 10g Enterprise Edition Release 10.2.0.2.0
    Connected as crm
    SQL> set serveroutput on
    SQL>
    SQL> DECLARE
      2    l_rec crm_pps_cards_sz%ROWTYPE;
      3    CURSOR c IS
      4      SELECT * FROM crm_pps_cards_sz t WHERE t.card_no =
      5      (SELECT MIN(card_no) card FROM crm_pps_cards_sz)
      6      FOR UPDATE NOWAIT SKIP LOCKED;
      7 
      8  BEGIN
      9    OPEN c;
    10    FETCH c
    11      INTO l_rec;
    12    CLOSE c;
    13    dbms_output.put_line('Card Allocated ' || l_rec.card_no);
    14 
    15  END;
    16  /
    Card Allocated 6338079966430591
    PL/SQL procedure successfully completed
    SQL>
    Thread - 2
    Connected to Oracle Database 10g Enterprise Edition Release 10.2.0.2.0
    Connected as crm
    SQL> set serveroutput on
    SQL>
    SQL> DECLARE
      2    l_rec crm_pps_cards_sz%ROWTYPE;
      3    CURSOR c IS
      4      SELECT * FROM crm_pps_cards_sz t WHERE t.card_no =
      5      (SELECT MIN(card_no) card FROM crm_pps_cards_sz)
      6      FOR UPDATE NOWAIT SKIP LOCKED;
      7 
      8  BEGIN
      9    OPEN c;
    10    FETCH c
    11      INTO l_rec;
    12    CLOSE c;
    13    dbms_output.put_line('Card Allocated ' || l_rec.card_no);
    14 
    15  END;
    16  /
    Card Allocated
    PL/SQL procedure successfully completed
    SQL> My concern is that it must allocate in the order
    6338079966430591
    6338079973369543
    ....

    It is because MIN(ard_no) is able to find value from table which is locked by you thread 1 and thread 1 mentioned NOWAIT thus it thread 2 went out without getting anything.
    Please check my reply to your duplicate thread "row level locking" .

  • IMic recording level.

    I'm using the iMic USB interface to record drums but the volume control for Real Instrument is "greyed out"... can't be adjusted (it's "locked" all the way to the left). The computer preferences recognize and receives the input device. But I can't raise the input to a recordable level in GB. Is this a software problem?
    I can record without any problems using Audacity. But why won't GarageBand allow me to adjust the recording level?
    I have tried reinstalling OSX and GarageBand but I still have the same problem.
    There's nothing wrong with the iMic because it works with Audacity.
    Any ideas?

    Hmmm well it appears that it is working. I've discovered that I am able to record, but the slider in GB is still greyed out so I can't adjust the recording level; but it seems to be ignoring the GB setting and just looking to the system preferences for the mic level. So I can only assume that it must be a software fault with GB.
    Thanks for your help!

  • Pl sql row level locking with wait ?

    Hi,
    I am using oracle 10g.
    I am new to Oracle locks. I have two tables Table1(id_no, employee, salary) and Table2(id_no, employee, salary).
    I need to pull any requested row from Table1 into Table2 only once on demand. I have a procedure to pull data and there could be more than one requests try to call same procedure to pull a row from Table1 into Table2 at any given time.
    I coded below to achieve row level lock. if one transaction gets row level lock on Table1 at 2, so other Transactions should wait till the lock is released at line 2 or 5 to avoid duplicates.
    But below code is not working, I am getting duplicates when I call this using two concurrent java threads.
    How do I control this concurrency issue so that I can avoid duplicate entries in Table2. Could any one please help?
    1.begin
    2.select 0 into emp_cnt
    3.from Table1 where id=id_no
    4.for update;
    5.update Table1 set employee='xyz'
    6.where id=id_no;
    7.select count(*) into table2_cnt from Table2 where id=id_no;
    8.if(table2_cnt =0) then
    9.code to insert above row from Table1 to Table2;
    10.end if;
    11.commit;
    12.End;
    Edited by: 980916 on Jan 9, 2013 5:48 PM

    Welcome to the forums and welcome to Oracle.
    Lets establish one thing right from the beginning ... the Oracle Database is not a Microsoft product.
    There is no general reason to use row level locks, you should not want to use row level locks, you don't need row level locks, and you will almost never have any valid reason to consider row level locks.
    That said there are two situations were it may be necessary to lock a row prior to an update or delete (possibly in a merge) and in those cases you want to use the built-in SELECT FOR UPDATE syntax. (Demo here: http://www.morganslibrary.org/reference/deadlocks.html#dlfu). But we should be clear here ... one rarely needs to use this locking mechanism as the chances of a collision in a well designed application are essentially zero.
    Also as you are new to Oracle please explore the dynamic performance view V$RESERVED_WORDS and do not name objects, columns, etc. with reserved word names not that there is an excuse in any product to name a column "ID." Something Joe Celko has railed about for decades and a tradition I think we should all follow.
    In the case of your posted code example (btw please read the FAQ and learn how to use tags) the solution is SELECT FOR UPDATE if locking can be justified which is unlikely.
    Edited by: damorgan on Jan 9, 2013 6:11 PM                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Record Level Adjust for Audio in Voice Memo or Video Recorder

    I would like to request that Apple allow me to adjust the record audio volume level when recording in Voice Memo or Video Recorder modes. Often I find that the audio is distorting and most times I cannot step back far enough to avoid distortion levels. While I love the ability to SEE the audio level in Voice Memo mode, I am hoping that it is only a matter of firmware upgrade to be able to ADJUST the record level.
    Also, if it is possible, it would be great to see some indication of audio level when recording video... something simple like a bar graph with green, yellow and red bars with the highest level reached sticking for a few seconds so that I can tell what the level is.
    An alternate solution (if none of the above is possible in a firmware update) would be to automatically adjust the recording level to prevent audio distortion.
    Thanks for the great iPod and here's hoping for a great firmware update in the near future!

    Thanks, I've submitted my recommendation to Apple.

  • Audigy 4 Pro Low Recording Levels/Master Knob/OSD probl

    I purchased a second-hand Audigy 4 Pro. I was not given the software disk but managed to install the latest drivers and get it to play MP3s. I use Adobe Audition to record my old tapes to MP3 and record my attempts at guitar. With my SBLi've I had no problem. I bought the Pro because of the ease of using the breakout box. However I have some quesions about some problems I am having. ) Since I have no Creative software, just Win XP Mixer I don't seem to be able to control the input levels from either the mixer or the box. I have a tape deck using RCA to Line In 3 and an electric and acoustic guitar to Line In 2. The mixer record levels seem to have no effect. I can record but nothing seems to be much more than -20db or so at most. Could this be because Adobe Audition only shows Line In 3 L (ie one channel only)? Could this be because of the much greater dynamic range of the Audigy 4 compared to the SBLi've Value? Do I need additional Creative software and if so what and how to get it please?2) The Master knob on the breakout box just spins round and round without sto
    ps.
    In other words you can rotate it in either direction ad infinitum. Is this correct? Pushing it in and out does cause the mute to work fine. 3) The help file talks about an On Screen Display associated with the remote. I don't have one when I use the remote, even when I press the Display button. Again, do I need Creative software for the remote? I have a yellow question mark against Multimedia Audio Control in my device list. ThanksMessage Edited by Dunkelmann on 2-23-200607:22 PM
    Message Edited by Dunkelmann on 2-23-200607:43 PM
    Message Edited by Dunkelmann on 2-23-200608: PM
    Message Edited by Dunkelmann on 2-23-200608:5 PM

    Wow these forums still suck. You have easy questions and no one bothered to help you out. I registered jsut to answer them for you although you probably already figured it all out. . It seems that loudness is optomized by creatives own drivers. What you described was also true back when you could use the e-mu driver hacks before creative bought e-mu. 2. The master knob indeed spins for infinity, obviously with no effect once you get to either end. This sucks becasue i have OCD and constanly spin this thing all kinds of ways. THey should have used the same system as the line-/mic knob. Only God and the engineer will ever know why they did this. 3 Yes. The on screen display is pat of the creative media player app.
    So to solve all your problems, you can get the full software package from creative.com under the support menu. Just follow the menu options for your device. The software requires that you have the hardware which you do so the software is free. One more problem you WILL have. The software doesnt install under XP. You have to enter windows safe mode and install it from there otherwise the whole thing freezes up during the start of the install process. Fun times!

  • Any option to restrict SE16 record level access based on company code?

    Hi All,
    I have a requirement to restrict record level access in SE16 based on company code.
    Our SAP system has two company codes. The requirement is that users of one company code should not be able to see records of other company code in SE16.
    Is it possible through some exits/badis/other methods?
    Thanks in advance.
    Regards,
    Arun Mohan

    You could write a small front end that accepts the company code, applies custom authorization code for each value and retains or removes, then calls the transaction and enters the selections the user requested and that your authorization check resulting in "passing"....  Of course, you'd have to block those users from "pure" SE16...   I once worked in situation similar, users in one country couldn't see USA data, etc. I think someone wrote an entire new program, called by ZSE16, for that.

  • Recording Level Sli

    I have the X-Fi Fatality sound card. For some reason, (and overnight), the recording level slider won't function any more. The message in the recording status window says "Follow Mixer Settings". I don't want that!? I want to be able to control the recording level from the player window as I always have. Does anyone know how to turn off the "Follow Mixer Settings" option? Thanks!

    Found the answer. For some reason, the "Sound & Audio Devices" in Control Panel didn't have the "Use Only Default Devices" checked. This was because I installed a Logitech HD WebCam, with its own microphone. That little check box somehow got unchecked. Not only did this fix the problem, but it also fixed "Smart Recorder", which was telling me that I didn't have an audio device. Everything's good now.

  • Line In Recording Level Adjustment

    I am recording from a tape recorder to the hard drive. I have done this a lot over the years. Suddenly I am no longer able to adjust the line in recording level. I have always before gone to Control Panel/Hardware and Sound/Sound (recording tab), Click Line In, then click on Levels. When I adjust the level, either lower or higher, it does nothing to change the sound level. Can aynone please tell me why this feature isn't working any longer on my computer. Could some other setting have gotten changed? Where should I look? Thanks!!!!

    Have you tried to discuss it with mixer manufacturer?
    I mean they know own product very well and have best experiences with it.
    I presume they have tested it on different hardware platforms and different operating systems so I believe they are the right address where you can ask for help.
    In control panel you have standard options for sound but maybe you need something specific for connected mixer.

  • Recording Level?

    New to Logic, coming from garageband and I have a quick, probably embarrassingly easy question, but in Garageband when recording from an external mic there's a slider that can set the recording level, to prevent clipping. Is there a way to do this when recording into Logic? Thanks.

    No. This would only be a problem if you are plugging a mic directly into the computer (you're not doing that, are you?)
    Any external audio interface you might use would have a level control. If you have not yet thought about getting an external interface, I suggest you search these forums for suggestions... there are many threads about this. I assume that you have upgraded to logic to have more control over your music than garage band will allow. As part of that process, a decent interface would seem mandatory (and a decent mic, of course... there are also many threads about this)
    And in any case, when you're setting the level, you need to do more than just avoid clipping. Assuming you are recording in 24bit mode (you are, aren't you?) it makes a lot of sense to set your levels so that they are peaking at least 6 - 10 db below max. This doesn't look as pretty on the meters, but by the time you put them through a number of plugins and send them all to busses and outputs, that extra headroom will really open up your recordings so they don't sound so digital and squashed. There are also many threads about this.
    Welcome to the big bad world!

  • Change the recording level for recording with Thunderbolt-Firewire-Mixer

    Hey,
    I just bought a PHONIC Helix Board 24 Universal for recording some music via Firewire.
    Because my IMac has no Firewire-slot, I am using a Thunderbolt-Firewire-Adapter and a Firewire 400-800 cable.
    If I try to record some music it sounds really horrible.
    It seems that the reason is the recording level which can be changed while using the internal micro but not with firewire-Thunderbolt.
    The recording level is set on max, resulting in overmodulation and noise.
    Is there any way to adujust the recording level?
    Thank you in advance!
    Kay

    Hello Jshen6,
    Have you tried looking at the examples in LabVIEW under Hardware Input and Output>>Synchronization? The Analog Input-Synchronization.vi example shows you how to synchronize AI across multiple devices in various configurations and for various types of hardware. Would you mind listing what hardware you are using? Are all three devices taking the same data (voltage, strain, acceleration, etc)?
    Jonathan L.
    Applications Engineer
    National Instruments

Maybe you are looking for