09-23-2008 5:10 AM
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.
09-23-2008 5:26 AM
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
09-23-2008 5:51 AM
thanks for your help.
but i don't want to really update the table until I/F file is outputed correctly.
09-23-2008 5:36 AM
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
09-23-2008 6:01 AM
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