Problem solve Get help with specific problems with your technologies, process and projects.

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.

move itab_buffer to itab1-fields.
 modify itab1.
This was last published in April 2002

Dig Deeper on SAP ABAP

Start the conversation

Send me notifications when other members comment.

By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Please create a username to comment.