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: 

Regarding commit work

Former Member
0 Kudos

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

3 REPLIES 3

Former Member
0 Kudos

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

Former Member
0 Kudos

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.

former_member195402
Active Contributor
0 Kudos

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