‎2008 Jan 29 11:38 AM
Hi Experts,
I have the requirements where i need to update the Database table for only two fields, But the Update should happen for every 1000 records for all the records. If one record has error none of the records should get updated in the database table.
Appreciate if you have a quick response.
Regards,
Shankar
‎2008 Jan 29 12:07 PM
1) use a counter in you loop.
2) use command rollback work (look F1)
A.
‎2008 Jan 29 12:11 PM
Hi,
Copy the DB table into an internal table.
Loop at Internal table.
if sy-tabix is a multiple of '1000' update the db table.
endloop.
Reawrd if helpfull.
Regards Madhu.
‎2008 Jan 29 12:14 PM
You should have your 1000 records in an internal table with the same structure as the database table.
Then you use:
UPDATE dbtab FROM TABLE itab.then you check for SY-SUBRC. If it equals 0 it means that all entries were updated. In the other hand, if it's 4 then at least one row could not be updated. The code should be:
IF SY-SUBRC EQ 0.
COMMIT WORK.
ELSE.
ROLLBACK WORK.
MESSAGE eXXX.
ENDIF.In the message you can specify the number of rows that contains error, because in SY-DBCNT the number of updated rows are stored. Then if you know you have 1000 lines in the internal table you can do:
error = 1000 - SY-DBCNT.
MESSAGE e000 WITH 'There where ' error ' lines with errors'.I hope it helps, reward points please.