‎2009 May 02 12:15 PM
I want to keep a lock on inserting the data while the other user is editing the same data so that false data is not entered.
‎2009 May 02 12:54 PM
Hi Sami ,
Create a lock object for that table .
Go to SE11 transaction and create a lock object for the table .Custom lock object
name should be start with EY or EZ. After activating lock object Function Module will be
generated automatically.Function Modules name will be like---
ENQUEUE_<LOCK_OBJECT_NAME> and DEQUEUE_<LOCK_OBJECT_NAME>.
First call the ENQUEUE function module to set the lock for your table.
Then Update the table as per your requirement.
After that unlock the table calling the DEQUEUE function Module.
For example you have created a lock object EZSFLIGHT for the SFLIGHT table .
So first lock the table , then update then release the lock.
Check this code ---
DATA : t_itab like table of SFLIGHT,
fs_itab like SFLIGHT.
fs_itab-carrid = 'AA'.
fs_itab-connid = '0017'.
.
.
.
APPEND fs_itab TO t_itab.
.
.
.
CALL FUNCTION 'ENQUE_EZSFLIGHT' " SET lock to the table
EXPORTING
CARRID = ....
CONNID = ....
.
.
IF sy-subrc eq 0.
INSERT sflight from table t_itab. " Update the DB table
ENDIF.
CALL FUNCTION 'ENQUE_EZSFLIGHT' " Unlock the table
EXPORTING
CARRID = ....
CONNID = ....
.
.
Regards
Pinaki
‎2009 May 02 12:54 PM
Hi Sami ,
Create a lock object for that table .
Go to SE11 transaction and create a lock object for the table .Custom lock object
name should be start with EY or EZ. After activating lock object Function Module will be
generated automatically.Function Modules name will be like---
ENQUEUE_<LOCK_OBJECT_NAME> and DEQUEUE_<LOCK_OBJECT_NAME>.
First call the ENQUEUE function module to set the lock for your table.
Then Update the table as per your requirement.
After that unlock the table calling the DEQUEUE function Module.
For example you have created a lock object EZSFLIGHT for the SFLIGHT table .
So first lock the table , then update then release the lock.
Check this code ---
DATA : t_itab like table of SFLIGHT,
fs_itab like SFLIGHT.
fs_itab-carrid = 'AA'.
fs_itab-connid = '0017'.
.
.
.
APPEND fs_itab TO t_itab.
.
.
.
CALL FUNCTION 'ENQUE_EZSFLIGHT' " SET lock to the table
EXPORTING
CARRID = ....
CONNID = ....
.
.
IF sy-subrc eq 0.
INSERT sflight from table t_itab. " Update the DB table
ENDIF.
CALL FUNCTION 'ENQUE_EZSFLIGHT' " Unlock the table
EXPORTING
CARRID = ....
CONNID = ....
.
.
Regards
Pinaki
‎2009 May 02 12:57 PM
hi,
try to use the tcode SM31 or SM01 and check about the functionality of it satisfying the requierments.
Edited by: ricx .s on May 2, 2009 1:59 PM
‎2009 May 02 1:14 PM
Are you doing it with the help of program??
If yes, then use the following function modules.
ENQUEUE_E_TABLE
DEQUEUE_E_TABLE
Thanks,
Babu Kilari
‎2009 May 02 1:51 PM
I have an employee id which should be unique. Employee id is auto genereated. So it will find the max employee id and then add one to it to generate the new employee id. Now if two person open that form at same time then both person will see the same number. So I want to lock generating the employee id when one user has already filling data under that employee id.