While writing programs that access huge database tables or access db tables repeatedly (in a loop) etc., it is...
By submitting your personal information, you agree that TechTarget and its partners may contact you regarding relevant content, products and special offers.
a good idea to build a buffer internally within your program (in an internal table) and then access these tables rather than going to the database for each loop. One way to do this would be to build up an internal table at each call to the database (while looping) and check in this buffer internal table for a corresponding entry before actually going into the database tables to retrieve entries. A second way could be to dump selected entries into an internal table (using select f1, f2.....fn into table itab where
loop at itab1. read table itab_buffer key f1 = k1 ,,,,, fn = kn (binary search). If sy-subrc ne 0. select single relevant fields from dbtable where f1 =k1 , ,,,, fn = kn. move dbtable-fields to itab_buffer-fields. append itab_buffer. move dbtable-fields to itab1-fields. else. move itab_buffer to itab1-fields. modify itab1.