SAP Lock Concept - Wich User Locks my TCode

Hey Experts,
i am using the SAP Lock Concept in my Transaktion, but i have a problem to find out how to get the Name of the User how locks my Tcode.
I build in the Function 'ENQUEUE_EZ_SMARTFORMS',
after that i print out a Message thet the 'Tcode gets edit by another User at the moment'.
Now i want to replace 'another User ' with the User-Name of the User.
Thanks for Help

Hi,
fm ENQUEUE_READ will give you the informations you want.
Pass th name of thge lock object to parameter GNAME, pass the lock argument to parameter GARG and pass SPACE to argument GUNAME.
Sample:
* Call custom lock object
  CALL FUNCTION 'ENQUEUE_MYLOCKOBJ'
    EXPORTING
      sase           = xv_sase
      _scope         = '3' "till the end
    EXCEPTIONS
      foreign_lock   = 1
      system_failure = 2
      OTHERS         = 3.
* Check return code
  CASE  sy-subrc.
    WHEN  0.      "lock successful
      xv_lock                 =  'X'.
    WHEN  1.      "foreign lock
      xv_uname                =  text-unk.
      CONCATENATE                sy-mandt
                                 xv_sase
                           INTO  xv_garg.
      CLEAR                      xt_enq.
      CALL FUNCTION 'ENQUEUE_READ'
        EXPORTING
          gname  = xk_gname_sase
          garg   = xv_garg
          guname = space
        TABLES
          enq    = xt_enq
        EXCEPTIONS
          OTHERS = 4.
      IF  sy-subrc           EQ  0.
        READ  TABLE              xt_enq
                           INTO  xs_enq
                          INDEX  1.
        IF  sy-subrc         EQ  0.
          xv_uname            =  xs_enq-guname.
        ENDIF.
      ENDIF.
      MESSAGE  s000(38)
                   DISPLAY LIKE  'E'
                           WITH  text-sas
                                 xv_sase
                                 text-m07
                                 xv_uname.
      EXIT.
    WHEN  OTHERS.  "unknown lock error
      MESSAGE  s000(38)
                   DISPLAY LIKE  'E'
                           WITH  text-sas
                                 xv_sase
                                 text-m04
                                 sy-subrc.
      EXIT.
  ENDCASE.
Regards,
Klaus

Similar Messages

  • Lock a tcode for particular user

    Hi Experts
    i need to lock few transaction for particular users only. we have n number of roles and the transactions have been assigned to some tcodes to be reasticted  for a list of users. is there any method or program to built to restrict the users for few tcodes.is there any more query pl trigger me
    regards
    bala

    hi
    sagar:
    as you said if i start creating roles to restrict some users then there atleast 25 tcodes are there to restrict and 120 roles are to be analyzed and the job becomes hefty by creating roles and there will too many number of roles and it becomes confusion in future forecast. there fore i nedd any suggestion like that the userscan be restricted when they are trying to access that particular code or lock the screen or inform them to not access these tcodes thro some message or writing a program to restrict the users while the user exits. i have an idea but i dont know how it will work - ( I am not a ABAPER) there should be tcode or program which should list tcodes authorized for particular users and where they can be locked like SM01 ( but it will lock for all) but locking for particular users
    Am i more advanced??
    regards
    bala

  • An internal error was found in the SAP lock management system when opening

    Hello SDN Experts ,
    When i am trying to open any t-ocde in my productive system
    it is displaying an error message "An internal error was found in the SAP lock management system " , not only for me but also for all the users .
    Could please tell me what colud be the problem and solution for this??
    it's very urgent .....
    Thanks in Advance !
    Siva reddy

    Hi,
    Check in SM12 if tht particular Tcode is being locked by some other person.
    Else contact your basis team. There may be some auth issues.
    Regards,
    Lalit

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

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

  • 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

  • Implications of Changing WebDynpro Parameter: sap.locking.maxWaitInterval

    SAP [OSS note 1234847|https://service.sap.com/sap/support/notes/1234847] mentions changing the WebDynpro parameter sap.locking.maxWaitInterval
    What are the implications of setting this to 30 minutes or 1 hour?

    Hi Juan,
    Yes the value is in seconds. I raised the question with SAP OSS and they replied with a good answer:
    As the note 1234847 explains,s soon as a request for a user session is processed, the user session is blocked for the duration of the request i.e. there is always at most one thread that has acquired the lock of a user session.
    Concurrent requests which refer to the same user session (i.e. triggeredfrom the same browser process) are serialized and processed one after each other. If there is a request which blocks or hangs due to some waiting/blocking condition, then other concurrently incoming requests are waiting for a certain period of time that the user session lock is released. If they can't acquire the user session lock after this time interval, the waiting thread terminates with a LockException error page.
    In such cases, the "sap.locking.maxWaitInterval" is helpful. Depending on the requests, administrators can increase it.
    In previous cases, we have had customers increase it from 100s to 300s (or 500s) in the Web Dynpro default.properties, depending on their need.This will not make the server processing time slow, but there will be anextra buffer time so that the user request can pass through.
    Customers vary the values of the parameter depending on the long runningapplications.
    More information is available: http://help.sap.com/saphelp_nwce71/helpdata/en/43/8a1a8ece230c8ce10000000a11466f/content.htm
    SAP note 1113811 also provides some info..
    However, if even after increasing this parameter, if there are locking issues, then this can be due to a application error. We will
    need to anayse a thread dump to check the status of the threads during the locking process. As you are aware, it is the java threads that are responsible for the actual carrying out of the server tasks, akin to the ABAP work processes.
    SAP Note No. 710154-How to create a thread dump for the J2EE Engine

  • How to check who locked the Tcode in SM01

    Hi to all experts,
    Is there a way to check who locked the Tcode in SM01 or in table TSTC?
    Thanks in advance.
    BR,
    Nancy

    Dear Nancy,
    Check the thread,
    [sm01 transaction logs;
    Regards,

  • Table overflowed  when trying to sap locks in the table..

    Dear ALL,
      when trying to sap locks in the table then its showing table overflowed. can telle the actual reason.
    Reagards.
    ASHUTOSH

    Hi, ALL
    suddenly sap PP persons execute the report, " errors comes as last msg  table overflow" whats the main reasons. i konw my self it automatically resize the table.
    Regards,
    ASHUTOSH

  • Online Consistent brbackup - How does SAP lock the archive files?

    With an Oracle online consistent brbacup, i believe that SAP locks the archive log files so they are not deleted during the backup.
    How do they do this?
    If a backup crashes how do I unlock these locks?

    Here is the statement (from the netbackup trace)  that caused brachive to stop.
    Set file /oracle/BP1/oraarch/BP1arch1_207989.dbf to QUIESCE status.
    Here is relevenmat part of the NetBAckup/backint log...
    5:21:36.691 [11248] <4> adjustObjectStatus: File </oracle/BP1/oraarch/BP1arch1_207989.dbf> in VxBSA_INPROGRESS status. No ch
    ange of status needed.
    15:21:36.691 [11248] <4> adjustObjectStatus: Done.
    15:21:36.691 [11248] <4> VxBSAWaitForFileListStatus: INF - entering WaitForFileListStatus.
    15:21:36.691 [11248] <4> bsa_handle_std_backup: INF - entering bsa_handle_std_backup.
    15:21:36.691 [11248] <4> bsa_comm_w_bkar: INF - entering bsa_comm_w_bkar.
    15:21:38.714 [11248] <4> bsa_comm_w_bkar: Recieved bpbkar message: #END /oracle/BP1/oraarch/BP1arch1_207989.dbf
    15:21:38.714 [11248] <4> bsa_comm_w_bkar: Comparing physical file  path: /oracle/BP1/oraarch/BP1arch1_207989.dbf
    15:21:38.714 [11248] <4> bsa_comm_w_bkar: to file from bpbkar message:   /oracle/BP1/oraarch/BP1arch1_207989.dbf
    15:21:38.714 [11248] <4> bsa_comm_w_bkar: File paths matched.
    15:21:38.714 [11248] <4> bsa_comm_w_bkar: Set file /oracle/BP1/oraarch/BP1arch1_207989.dbf to VxBSA_UNQUIESCE status.
    15:21:38.714 [11248] <4> bsa_comm_w_bkar: Recieved bpbkar message: #BEGIN /oracle/BP1/oraarch/BP1arch1_207989.dbf
    15:21:38.714 [11248] <4> bsa_comm_w_bkar: Comparing physical file  path: /oracle/BP1/oraarch/BP1arch1_207989.dbf
    15:21:38.714 [11248] <4> bsa_comm_w_bkar: to file from bpbkar message:   /oracle/BP1/oraarch/BP1arch1_207989.dbf
    15:21:38.714 [11248] <4> bsa_comm_w_bkar: File paths matched.
    15:21:38.714 [11248] <4> bsa_comm_w_bkar: Set file /oracle/BP1/oraarch/BP1arch1_207989.dbf to QUIESCE status.
    15:21:38.714 [11248] <4> bsa_comm_w_bkar: File /oracle/BP1/oraarch/BP1arch1_207989.dbf not in VxBSA_NOTREADY state.
    15:21:38.714 [11248] <16> bsa_comm_w_bkar: Can't change state.
    15:21:38.714 [11248] <4> do_file_backup: The sequence of calls is incorrect.
    15:21:38.715 [11248] <4> do_backup: Exit with status: <2>.
    15:21:38.715 [11248] <4> /usr/sap/BP1/SYS/exe/run/backint 6.0: **************************************************************

  • Lock the Tcode through program

    Hi All,
    I has write a program for lock the tcode for that I am using FM:-RSAU_WRITE_SM01_LOG,When I pass Input for  FM like below
    Tcode and lock ,
    It will run correct but the database updation is not takes place..
    Can any one guide to resolve the Issue..
    Please tell me if there is any fm to lock the tcode ..
    Thanks In advance.
    Regards,
    Nagesh

    Hi,
    If your ultimate motive is to update database,then why you are trying to lock a Tcode? You should lock the database table instead,then do your update work and then release the lock. That's it. I think it would be better if you create lock object from SE11 of your particular database table. Call ENQUEUE function module. Update DB table. Then call DEQUEUE function module and you are done.
    Let me know if you face any problems.Hope this would help.
    BR,
    Atanu

  • 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

  • FM or CL to lock/unlock TCODEs

    Hi,
    i'm looking for a FM or CL to lock/unlock TCODEs via a Report.
    I don't want to do it via SM01.
    Thanks.
    Regards, Dieter

    To my knowledge, there is no function module or class/method to do this.  You can do it by doing a direct database update to table TSTC.
    The field CINFO holds the value  A0  when locked,   when unlocked, it holds the value  80 .
    Regards,
    Rich Heilman

  • Table contain user name and tcode

    Dear Experts,
    Can you tell me which Table contained user name and tcode field?
    Thanks and Best regards,
    wilson

    You need to be even more carefull with parameter transactions.
    If SU24 is not maintained for them, PFCG will pull the proposals from the core transaction (via which the parameters are used in the skip screen feature...). If the core transaction has authority proposals for S_TCODE, then you will get those tcodes and their proposals as well.
    A carefull choice of menu objects (not only limited to Tcodes), taking heed of SU24 defaults and tuning it to meet your needs is the key. But it requires organizational discipline and good training, otherwise rather dont use it for anything other than important objects which you want to control manually only, even if your business roles are a mess.
    You can also restrict the authorizations of the security admins for example (as unpopular as that may sound... to segregate authorization concept development (SU24 etc), role building development (PFCG etc) and user administration (SU01 etc). Object S_USER_TCD also has a field called TCD...
    There are also other objects (as Dipanjan has pointed out) which have TCD as a field of an object which is not S_TCODE. In addition to I_TCODE, Q_TCODE, P_TCODE, see also S_IDOCMONI for example.
    To be honest I have given up on trying to find them all
    The easiest solution is to use the menu and maintain SU24 when the transaction is configured or the application is developed and tested. That is what SAP does as well in SU22. It is more work upfront, but more sustainable in the long run.
    If your users (and auditors) only see the menu (and use the SUIM --> Executable transactions) options, then you can get away with it in the short or even medium term. Latest when someone else need to maintain the roles they will hate it...
    My 2 cents,
    Julius

Maybe you are looking for