Buffering internally within your program

It is a good idea to build a buffer internally within your programs. Here's why!

While writing programs that access huge database tables or access db tables repeatedly (in a loop) etc., it is

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 ) and then loop on the internal table to retrieve data rather than accessing the database at each loop.


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.
This was first published in April 2002

Dig deeper on SAP ABAP

Pro+

Features

Enjoy the benefits of Pro+ membership, learn more and join.

0 comments

Oldest 

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

SearchManufacturingERP

SearchOracle

SearchDataManagement

SearchAWS

SearchBusinessAnalytics

SearchCRM

SearchContentManagement

SearchFinancialApplications

Close