Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Lock on inserting the data

Former Member
0 Likes
756

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.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
708

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

4 REPLIES 4
Read only

Former Member
0 Likes
709

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

Read only

Former Member
0 Likes
708

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

Read only

Former Member
0 Likes
708

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

Read only

Former Member
0 Likes
708

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.