Show TOC

Background documentationExecute and Print Locate this document in the navigation structure

 

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-SIZE addition and never set any page length using the LINE-COUNT addition of the REPORT statement.

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).

Syntax Syntax

  1. REPORT demo_list_print_1 NO STANDARD PAGE HEADING LINE-COUNT 0(2).
  2. PARAMETERS p TYPE i.
  3. INITIALIZATION.
  4.   CALL FUNCTION 'SET_PRINT_PARAMETERS'
  5.        EXPORTING
  6.             archive_mode   = '3'
  7.             copies         = '5'
  8.             department     = 'BASIS'
  9.             destination    = 'LT50'
  10.             expiration     = '0'
  11.             immediately    = 'X'
  12.             layout         = 'X_65_132'
  13.             line_count     = 54
  14.             line_size      = 20
  15.             list_name      = 'Test'
  16.             list_text      = 'Test for User''s Guide'
  17.             new_list_id    = 'X'
  18.             receiver       = 'KELLERH'
  19.             release        = ' '
  20.             sap_cover_page = 'X'.
  21. START-OF-SELECTION.
  22.   DO p TIMES.
  23.     WRITE / sy-index.
  24.   ENDDO.
  25. TOP-OF-PAGE.
  26.   WRITE: 'Page', sy-pagno.
  27.   ULINE.
  28. END-OF-PAGE.
  29.   ULINE.
  30.   WRITE: 'End of', sy-pagno.
End of the source code.

After executing this program, the user can enter a value for parameter p on the selection screen (for example 100) and choose Execute and Print. The following dialog box appears:

This graphic is explained in the accompanying text.

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.

First page:

Syntax Syntax

  1. Page     1
  2. --------------------
  3.          1
  4.          2
  5.          3
  6.    .....
  7.         49
  8.         50
  9. --------------------
  10. End of     1
End of the source code.

Second page:

Syntax Syntax

  1. Page     2
  2. --------------------
  3.         58
  4.         59
  5.         60
  6.    .....
  7.         99
  8.        100
  9. --------------------
  10. End of     2
End of the source code.

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.