06-14-2011 2:41 AM
Hi all,
I am using update statement 2 times for a single record in table and here I am using a single enqueue and dequeue statement for this purpose. I have 2 queries
1. Is it advisable to use a single enqueue dequeue statement while I am updating 2 times a single record of a table. Or each
update statement we have to use enqueue separately.
2. Can I use commit statement after the dequeue statment. or I have to use before the dequeue statement
enqueue ....
if ..
update table .....
if sy-subrc = 0.
flag = 'X'.
endif.
if...
update table.....
if sy-subrc = 0.
flag = 'X'.
endif.
endif.
dequeue ...
if flag = 'X'.
commit.
endif.
Regards
Mani
06-14-2011 5:49 AM
Hi Mani,
Not sure on why you want to use the update statement twice, anyways my suggestion is to use just one update statement
if ..
modify ITAB/Work Area with the corresponding data
if sy-subrc = 0.
flag = 'X'.
endif.
if...
modify ITAB/Work Area with the corresponding data
if sy-subrc = 0.
flag = 'X'.
endif.
endif.
if flag = 'X'.
enqueue ....
update table.....
commit.
dequeue ...
endif.
Regards,
Chen
06-14-2011 5:53 AM
Hi,
If you are updating the same record , then teh enqueue would anyways have locked that entry.
So i dont think you need a separate lock.
But just wondering why 2 updates.
06-14-2011 5:59 AM
Hi Mani,
this depends on the setting of the parameter _SCOPE in ENQUEUE fm call.
You can use the lock for both updates.
If you have _SCOPE = 1 you can have a COMMIT WORK after each update (or one COMMIT after both updates) and have to DEQUEUE it afterwards; if _SCOPE is 2 or 3 a COMMIT WORK automatically dequeues the lock and in this case you need no DEQUEUE fm before COMMIT WORK.
Regards,
Klaus