If I loop the internal table in the driver program at the point of the function modules, the print preview gets repeated.
1) Did you create a table or a template? Your question uses the word "template" several times. Please understand there is a significant difference between the two in a Smart Form. A template is designed primarily for fixed information, such as a grid in a secondary window. A table – which is what you need here – is designed for information of unknown height (until runtime, anyway) but fixed width. It is always found inside a MAIN window.
2) Does your form consist of multiple mapped pages? A form can consist of a single named page (e.g. FIRST). However, it needs to be told what to do when that page fills up. At that point, it can print info to the same page (i.e. a second page is generated with the same look and feel), or to a different page, or to none at all.
3) Have you verified that the entire table is passing into the form? Perhaps there is something amiss in the way data is passed or declared. To check this, set a break-point in your Initialization section and pass the internal table into it. Alternately, create a program node with a break-point inside the table and pass the table's work area into it. See what the values are at that point.
4) Are the nodes which print the table's work area properly contained within the table body? Sometimes it is difficult to tell whether a node is inside another node or at the same level. A quick way to check this is to expand and collapse the table and see whether these nodes appear then disappear when you do so.
Since you are working with a Smart Form, I would recommend against putting the loop inside the print program itself. Output loops there are designed for dealing with changes to header info, not line item info. This is a major distinction between SAPscript and Smart Forms.
This was first published in August 2005