‎2009 Nov 02 7:29 AM
HI All
I have table that called by service (this process can take time since the table is full with data ) ,
the problem is that the table can be updated during the service read call which can cause inconsistency ,i read on the help about the read lock and exclusive lock i i think that i should use both of them but i am not sure ,
if i need to use both, how should i use it ?
before the select i use the read lock or before the update ?
or for the update process i should use both of the locks ..
any simple example will help .
Regards
JOy
‎2009 Nov 02 12:44 PM
Basically you don't want anyone to modify the data when your service is reading it.
Putting a lock on data from service before reading it will prevernt any changes being made during the read process.
In update program you will have to make change (if it is not there already) so that it first request for lock and if request is successful then carry on changes.
‎2009 Nov 02 9:05 AM
‎2009 Nov 02 12:29 PM
‎2009 Nov 02 12:44 PM
Basically you don't want anyone to modify the data when your service is reading it.
Putting a lock on data from service before reading it will prevernt any changes being made during the read process.
In update program you will have to make change (if it is not there already) so that it first request for lock and if request is successful then carry on changes.
‎2009 Nov 02 1:00 PM
HI ,
basically what i need to use is Exclusive lock for update, multiple locks for the read process
but i need some simple example how i should use this both locks for the table
Thanks Joy
Edited by: Joy Stpr on Nov 2, 2009 2:00 PM
‎2009 Nov 02 1:05 PM
Hi,
Have a look at this links
http://help.sap.com/saphelp_nw04s/helpdata/en/af/22ab01dd0b11d1952000a0c929b3c3/content.htm
Regards,
Lakshman.,
‎2009 Nov 02 1:10 PM
Hi Joy
I think u're speaking about SAP lock, this is a logical lock and not a database lock.
So it's not really important if the lock is Exclusive or Read, because u need to check the lock and then decide what to do if the lock is active.
After creating the lock by SE11, the system generates the fms in order to lock and unlock the lock.
Now the problem is u should place the control of the lock in the service and in all report can update your table.
Every report should abort the running if the lock is actve.
Do u really want to do this?
Max
‎2009 Nov 02 2:58 PM
Hi Max
Thanks
i have to do this .
there is scheduled job which update the table and can run for 1 hour (and can have 1000000 records ).
the web service is call to the table data with paging mechanism ( i.e. for 100 records in every service call ) the problem is if the service initiate a call and get 500 records and the update process is started ,this can cause to inconsistency so for that i need the locks mechanism .
my opinion is to do Exclusive lock for update, multiple locks for read.
but i am not sure about it since i am new to this topic .
in the update process do i need to lock all the table ?
since i update the table via
MOdify Z table from itab
and for read i call every time for 100 or 200 records (select upto 100/200 users ) how should i lock it ?
Thanks
Joy
‎2009 Nov 02 4:03 PM
Hi
U can create a lock object for your Z-TABLE by SE11, the name convention for the lock should be E<table name>: while activing it, the system generates 2 function module to lock and unlock, the function module will be called:
- ENQUEUE_<lock object> to set the lock
- DEQUEUE_<lock object> to delete the lock
In both your programs: web service and job u should call the fm to set the lock ENQUEUE_<lock object>, if this fm returns sy-subrc equal to 0, it means the lock is set else the lock is just set, in this last case u should decide what u need to do.
Case: A) Web service starts and it gets a lock active: I suppose u should stop the service because it means the job is running;
Case B) Job start and it gets a lock active: it means a web service is running, so probably u need to stop the job (?),
u could have a conflict situation if job is a priority higher than web service
U can use the fm DEQUEUE_<lock object> to delete the job, but u need to consider the lock is automatically deleted at the end of a task, so as soon as the job iand web service is finished.
Max
‎2009 Nov 02 4:07 PM
>
> there is scheduled job which update the table and can run for 1 hour (and can have 1000000 records ).
>
Based on number of records you are updating, I will not recommend to put lock for each record as it will possibly overflow the Lock table.
‎2009 Nov 02 4:30 PM
HI MAx
Thanks ,
in the update process do i need to lock all the table ?
since i update the table via
MOdify Z table from itab
the other option is to lock every record and modify it ,
what is your opinion ?
and for read i call every time for 100 or 200 records (select upto 100/200 users ) how should i lock it for every recored ?
Thanks again
joy
Edited by: Joy Stpr on Nov 3, 2009 8:38 AM
‎2009 Nov 03 9:18 AM
Hi,
During updation of a table you need to lock the record which you want to update.
Using the primary keys combination you can lock the record which you are updating.These key combinations should be passed as arguments to the lock function module .
Regards,
Lakshman.
Edited by: Lakshman N on Nov 4, 2009 6:26 AM
‎2009 Nov 03 11:38 AM
Hi
U need to lock the whole table and not a single record
Remember it's only a logic lock, so u can avoid a SQL updating, but u can check the result returned by fm to set the lock and decide what u need to do
Max