To achieve a good performance when printing a form, you must separate data selection from the use of data in the form. Thus you can bundle database operations before you start processing the form.
Before you retrieve data, you should know:
Write an ABAP program to retrieve data or include a retrieval routine into your application. This code consists of statements that select data from the database according to certain selection criteria. Store the retrieved data in internal tables, structures, or variables and transfer it to the form in one step.
While you initialize the form, you can format the data, which you passed to the form, for output in the form. Formatting data in the form and not in the application program allows you to use one application program for several forms with different formatting routines.
You store the application data in internal tables of the application program. Since you know now which table types occur, you can define a form interface to transfer this data to the appropriate form.