Application Development 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: 

lock table exclusive ?

Former Member
0 Kudos

hi,

is it possible to 'lock' an table for a specific time ?

i have a Z-table where rows are inserted all the day.

3 times a day i have to read the table and send data to another system.

is it possible to 'lock' a table , so that only this program can exclusivly use it ? so that

the other places where there is a insert into table have to wait until table is unlocked again ?

i don't want to be rows inserted during the programm runs 3 times a day.

reg, Martin

1 ACCEPTED SOLUTION

Venkat_Sesha
Advisor
Advisor
0 Kudos

Hi ,

You can do it. The Lock Objects are created in SE11 with naming standard EZ.

whenever you create a Lock Object a FM is generated.

Now call the ENQUEUE by passing the paramerter as required and then Dequeue it.

For example: My Ztable is ZARS_TRHDR_T'

CALL FUNCTION 'DEQUEUE_EZARS_TRHDR_T'

EXPORTING

iface = pv_iface

idate = pv_idate

itime = pv_itime.

Similarly for ENQUEUE. Hope This Helps.

Thanks,

Bhargav

4 REPLIES 4

ThomasZloch
Active Contributor
0 Kudos

No problem, if the "other places" are properly setting locks while updating the table. Then your sender program can try to set the lock, if successful then process the data, if not successful wait until the lock has been released (the "other places" should use a similar logic).

Read further about SAP lock concept.

Thomas

Venkat_Sesha
Advisor
Advisor
0 Kudos

Hi ,

You can do it. The Lock Objects are created in SE11 with naming standard EZ.

whenever you create a Lock Object a FM is generated.

Now call the ENQUEUE by passing the paramerter as required and then Dequeue it.

For example: My Ztable is ZARS_TRHDR_T'

CALL FUNCTION 'DEQUEUE_EZARS_TRHDR_T'

EXPORTING

iface = pv_iface

idate = pv_idate

itime = pv_itime.

Similarly for ENQUEUE. Hope This Helps.

Thanks,

Bhargav

0 Kudos

hi v s,

when calling the 2 FM, is there anything i should do with the parameters iface, idate and itime, which

are export parameters ? how to fill it ?

can i be sure that other programs 'wait' until the table is unlocked again ?

b. reg, Martin

0 Kudos

when calling the 2 FM, is there anything i should do with the parameters iface, idate and itime, which

are export parameters ? how to fill it ?

can i be sure that other programs 'wait' until the table is unlocked again ?

Those are key fields specific to the table in the example. If you want the programs to 'wait', you have to use the built-in function parameter or program the wait in a loop yourself. Check the help files on ENQUEUE as Thomas has already suggested.