The easiest way of printing a list while creating it is for the user to choose Execute and Print on the selection screen of the executable program. The user can choose between displaying the list on the screen (choosing Execute) or printing it directly without displaying it (choosing Execute + print).
If the user chooses Execute and Print on the selection screen of the report, the system displays the Print Parameter dialog window before creating the list. The user enters the print parameters. You can use the function module SET_PRINT_PARAMETERS to pre-set values for this dialog window.
Consequently, you must program the list in such a way that it can both be displayed on the screen and printed on the printer. Therefore, do not specify a page width wider than 132 characters using the LINE-SIZEaddition and never set any page length using the LINE-COUNT addition of the REPORTstatement.
Using Execute and Print, the user can print only the basic list of the executable program. To print detail lists that you create during interactive events on the displayed list, use NEW-PAGE PRINT ON (see Printing from Within the Program).
REPORT demo_list_print_1 NO STANDARD PAGE HEADING LINE-COUNT 0(2).
PARAMETERS p TYPE i.
CALL FUNCTION 'SET_PRINT_PARAMETERS'
archive_mode = '3'
copies = '5'
department = 'BASIS'
destination = 'LT50'
expiration = '0'
immediately = 'X'
layout = 'X_65_132'
line_count = 54
line_size = 20
list_name = 'Test'
list_text = 'Test for User''s Guide'
new_list_id = 'X'
receiver = 'KELLERH'
release = ' '
sap_cover_page = 'X'.
DO p TIMES.
WRITE / sy-index.
WRITE: 'Page', sy-pagno.
WRITE: 'End of', sy-pagno.
After executing this program, the user can enter a value for parameter p on the selection screen (for example 100) and chooseExecute and Print. The following dialog box appears:
The function module SET_PRINT_PARAMETERS fills the input fields with the default values. Because of the function module, the Lines field is ready for input, even though the LINE-COUNT addition is used in the REPORT statement. The option, in this case, is needed to reserve space for two footer lines.
After choosing Print on the Print Parameter dialog window, the system displays the Archive Parameters dialog box, since the import parameter ARCHIV_MODE sets the archiving mode to Print and Archive.
If the user enters 100 for the parameter P on the selection screen, the system creates an SAP cover page and two print pages that look like this.
End of 1
End of 2
On each page, you can output up to 54 lines, including page header and footer lines. Note that the system triggers page breaks and creates page headers and footers exactly as described in Creating Complex Lists.
If the user chooses Execute on the selection screen instead of Execute + print, the system displays the list as one page and without page footer on the output screen.