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: 

commit work and process to update DB

Former Member
0 Kudos

I am programming a sap batch, in this program, it first select out all data needed to output to a I/F file, and then update these data's status as 'Outputed'.

so. i want to do it with the next logic:

1.select out all data needed to be outputed from table

2. update status

Loop :all records needed to be updated

1) sap lock:

lock table

2) do update

3) Unlock table

End loop

3.output I/F file

4.commit work

is there any problem with above logic? i want to update DB only if updating and I/F output are executed corretly. and sap lock is necessory? commit work is the last step, any problem?

thanks for your answer.

4 REPLIES 4

Former Member
0 Kudos

Hi

I think you can try the following sequence

1.select out all data needed to be outputed from table

2) sap lock:

lock table

3. update status

Loop :all records needed to be updated

4) do update

5.commit work

End loop

6) Unlock table

7.output I/F file

If you are locking at table level, you can do it outside loop.

Pls note - nobody will be able to update the table, unless the loop is complete

You need to do commit work for every record

Regards

MD

0 Kudos

thanks for your help.

but i don't want to really update the table until I/F file is outputed correctly.

Former Member
0 Kudos

Hi Yin,

You need to lock the table and then do the update process and after update then go for commit work and then unlock the table and then output the file.

Regards,

Chandra Sekhar

Former Member
0 Kudos

Hi,

You can try the alterations given below in the sequence:

1.select out all data needed to be outputed from table

2. output I/F file

IF output of IF file is successful..

Loop at table and

update the field to be updated i.e. STATUS field

ENDLOOP

1. sap lock: lock table

2. Do Update to SAP TABLE. Use command MODIFY db_tab FROM it_tab TRANSPORTING status.

3. Unlock table

4.commit work

Above given sequence will help you to improve performance for huge data...

Regards,

Kunjal