Let say we have a customized table ZCUST_INFO that holds a specific customer information with MANDT(client number) and KUNNR(customer number) as the key field.
So let's create a Lock Object for our customized table:
1. Go to transaction SE11
2. Click on Lock Object radio button and type-in EZCUST_INFO on name field and click on create button.
3. On Tables Tab, type-in ZCUST_INFO on name field and choose Write Lock on Lock Mode.
4. Go to Lock Parameter Tab and on the first row, type-in mandt on lock parameter, zcust_info on
table, and mandt on field.
5. On second row, type-in custnum on lock parameter, zcust_info on table, and kunnr on field.
6. Click save and activate.
Now let say we also have a dialog program for managing this the content of this table. We have screen 100 for our selection screen with customer number as selection parameter, screen 200 for editing screen, and screen 300 for display screen.
On the PBO of screen 200, let's add the code below.
CALL FUNCTION 'ENQUEUE_EZCUST_INFO'
EXPORTING
MODE_ZCUST_INFO = 'X'
MANDT = sy-mandt
CUSTNUM = <customer number from screen 100>
EXCEPTIONS
FOREIGN_LOCK = 1
SYSTEM_FAILURE = 2
OTHERS = 3.
IF sy-subrc = 1.
MESSAGE 'This record is currently locked by another user!' type 'I'.
leave to screen 300.
ENDIF.
The code above will request for lock on the table zcust_info specifically on the record specified on
the mandt and custnum parameter. If the record is already locked by another user, the user will be
prompted and will be redirected to screen 300 which is the display screen.
Lastly, on the PAI of screen 200, add the code below to release and unlock the object queued on the PBO:
CALL FUNCTION 'DEQUEUE_EZCUST_INFO'
EXPORTING
MODE_ZCUST_INFO = 'X'
MANDT = sy-mandt
CUSTNUM = <customer number from screen 100>
EXCEPTIONS
FOREIGN_LOCK = 1
SYSTEM_FAILURE = 2
OTHERS = 3.
if you want to publish or Add something on ERP, SAP , SAP FUNCTIONAL, SAP ABAP then mail us along with your email-id. contain must be yours email-id :- avinashkr_raj@yahoo.com(any email) email-id :- avinaskr_raj.abap@blogger.com
Go on link..
link us with ...
Showing posts with label LOCK Object. Show all posts
Showing posts with label LOCK Object. Show all posts
Monday, January 3, 2011
Lock Objects
Lock objects are used to manage database locking in your program. Locking is important in case you expect concurrent accesses to a database table.
You create lock objects in either SE11 or SE80 transactions (under the Dictionary Object in the navigation tree)
Each lock object you create is associated with a database table. You can choose by which fields in the table you lock. For example, in case you have an Employee table, you can choose to lock the table by the ID field of the table. After the creation of a locking object, two methods are available for your use – ENQUEUE_objectname and DEQUEUE_objectname, where objectname is the name of the lock object you created. The former allow you to lock an entry in the table, the latter releases the lock object.
There are many types of locks and we'll not discuss them here. SAP's official guide on locks can be found in the SAP Help. A nice step by step tutorial on locking objects can be found in
You create lock objects in either SE11 or SE80 transactions (under the Dictionary Object in the navigation tree)
Each lock object you create is associated with a database table. You can choose by which fields in the table you lock. For example, in case you have an Employee table, you can choose to lock the table by the ID field of the table. After the creation of a locking object, two methods are available for your use – ENQUEUE_objectname and DEQUEUE_objectname, where objectname is the name of the lock object you created. The former allow you to lock an entry in the table, the latter releases the lock object.
There are many types of locks and we'll not discuss them here. SAP's official guide on locks can be found in the SAP Help. A nice step by step tutorial on locking objects can be found in
Labels:
LOCK Object
Subscribe to:
Posts (Atom)
link us...
For Visitors
if you want to publish or Add something on ERP, SAP , SAP FUNCTIONAL, SAP ABAP then mail us along with your email-id. contain must be yours
email-id :- avinashkr_raj@yahoo.com(any email)
email-id :- avinaskr_raj.abap@blogger.com ( use only gmail)
email-id :- avinashkr_raj@yahoo.com(any email)
email-id :- avinaskr_raj.abap@blogger.com ( use only gmail)