SAP Lock Object basic concepts and basic operations SE11

Source: Internet
Author: User

 
 
I. Why should sap set a lock? 1. Maintain data consistency. If several users want to access the same resource, they need to find a synchronous access method to maintain data consistency. For example, in the flight booking system, you need to check whether there are any empty seats. During the check, you do not want others to modify the important data (the number of empty seats ). 2. It is not enough for the database management system to physically lock the row record to be modified. Other users must wait until the database lock is released to access this record. In the SAP system, the database lock is released when a new screen is displayed, because the screen change triggers an implicit dB commit. If the data is collected from several screens, and the data will be locked separately during this period, it is not enough to use the database lock alone. The SAP system has a global lock table on the application server layer, which can be used to set logical locks to lock related table entries and enqueue workflow to manage these locks. The SAP lock is a logical lock. It is possible that the table entries you lock do not exist in the database at all. 2. Create a lock object for the lock object and its corresponding FM in SE11. The custom Lock Object must start with EZ or ey. A lock object contains only one primary table, which can contain several secondary tables. There are three lock modes: E, S, and X. Set the fields in lock parameters to lock table entries. Mode e: This mode is set when data is changed. Mode S: No data needs to be changed, but the data to be displayed is not changed by others. Mode X: similar to E, but not accumulative, exclusive. If you successfully lock a lock object in a program, if the mode is E, other users cannot add any lock in the E, X, or S mode to the lock object; if you successfully lock a lock object in a program, if the mode is X, other users cannot add any lock in the E, X, or S mode to the lock object; if you successfully lock a lock object in a program, if the mode is s, other users cannot add the E and X locks to the lock object, but you can apply the S-mode lock. If you successfully lock a lock object in a program, if the mode is E, in this program, you can also apply the E and S modes to the lock object. The X mode is not supported. If you successfully lock a lock object in a program, if the mode is X, in this program, you cannot add a lock in the E, X, or S mode to the lock object. If you successfully lock a lock object in a program, if the mode is S, you can also add the S mode lock to the lock object in this program, if no other user adds the S-Mode Lock to it, you can also apply the e-Mode Lock to it. X mode is not supported. When the Lock Object is activated, the system automatically creates two FM, enqueue _ <Lock Object Name> and dequeue _ <Lock Object Name>, which are used to lock and unlock the Lock Object respectively. 3. Lock and unlock when a logical lock is used to lock a table entry, the system automatically writes records to the lock table. When you call the FM to set the lock, if the lock parameters parameter is not specified, the system locks the entire table. Of course, lock parameter: client is a bit special, if not specified, the default is SY-MANDT; if the corresponding client is specified, the corresponding table records on the corresponding client will be locked; if set to space, all clients are locked. When logical lock settings fail, there are two exceptions. One is exception: foreign_lock, which means the lock has been made; the other is exception: system_failure. In some cases, logical locks set successfully in the program are implicitly unlocked. For example, when the program ends (when the message type is a or X), use the leave program, leave to transaction statement, or enter/N in the command line and press Enter. At the end of the program, you can use the dequeue function module to unlock the program (if you do not write this, the program will be automatically unlocked at the end of the program). At this time, the system automatically deletes the corresponding records from the lock table. When the dequeue function module is used to unlock the instance, no exception is generated. To unlock all the logical locks you have created in the program, you can use FM: dequeue_all. 4. Manually unlock the sap lock. When the program exits abnormally, the SAP lock may not be removed in time, leading to subsequent failures. In this case, tcode: sm12 can be used to manually delete the lock.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.