The lock object technology can be used to prevent concurrent operations on databases.
The last function of SE11 is to create a Lock Object. For example, to lock the created database table, the name can be "E" + Table name.
After the name is set, click Create, enter the short text (description) of the lock object, and select the name of the table to be locked in the tables option, then, select "E" (dedicated, accumulative) in the lock parameter below. After setting, a lock object is created. In the lock parameter option, all primary keys in the default table are lock parameters. You can delete unnecessary parameters as needed.
Then, in the program, call the call function 'enqueue _ ez1_infnr 'and call function 'dequeue _ ez1_infnr' to lock and unlock the function in the program, the first function is used to lock the database before the program operates the database, and the last function is used to release the lock after the program operates the database. The Code is as follows:
Call function 'enqueue _ ez1_infnr'
Exporting
Mode_z1_infnr = 'E'
Mandt = sy-mandt
Proname = p_maktg
* Idnrk =
Werks = p_werks
* X_proname =''
* X_idnrk =''
* X_werks =''
_ Scope = '2'
* _ Wait =''
* _ Collect =''
Exceptions
Foreign_lock = 1
System_failure = 2
Others = 3
.
If sy-subrc <> 0.
Uname = sy-msgv1.
Message s001 with 'user 'uname' is modifying the project of this factory: 'p_maktg.
Stop.
Endif.
Select zpesinfnr ....
...
Call function 'dequeue _ ez1_infnr'
Exporting
Mode_z1_infnr = 'E'
Mandt = sy-mandt
SAP Lock Object