Show TOC

Background documentationPrinting Lists from a Called Program Locate this document in the navigation structure

 

To send the output of reports you call from within your program using SUBMIT to the spool system, you must use the SUBMIT statement with the TO SAP-SPOOL addition:

Syntax Syntax

  1. SUBMIT rep TO SAP-SPOOL
  2.              [params|SPOOL PARAMETERS pripar]
  3.              [ARCHIVE PARAMETERS arcpar]
  4.              [WITHOUT SPOOL DYNPRO].
End of the source code.

The SUBMIT statement is described in detail in the section Calling Executable Programs. If you use the TO SAP-SPOOL option, the list is formatted for printing while it is being created, and then sent to the spool system. The remaining additions set the print parameters.

Setting the Print Parameters

To define the print parameters, proceed as described with the NEW-PAGE PRINT ON statement:

You may set each print parameter individually using one of the params additions (see keyword documentation) or use the SUBMIT statement to execute a user dialog; however, to determine the print parameters, use the function module GET_PRINT_PARAMETERS only. The function module GET_PRINT_PARAMETERS decouples the user dialog from the SUBMIT statement, and guarantees a complete parameter set even without executing the user dialog. To determine the parameters, use only the additions SPOOL PARAMETERS and ARCHIVE PARAMETERS and, to suppress the user dialog of the SUBMIT statement, use the WITHOUT SPOOL DYNPRO option.

Syntax Syntax

The following executable program is connected to the logical database F1S.

  1. REPORT sapmzts1.
  2. TABLES spfli.
  3. GET spfli.
  4.   NEW-LINE.
  5.   WRITE: spfli-mandt, spfli-carrid, spfli-connid,
  6.   spfli-cityfrom, spfli-airpfrom, spfli-cityto,
  7.   spfli-airpto, spfli-fltime, spfli-deptime, spfli-arrtime,
  8.   spfli-distance, spfli-distid, spfli-fltype.
End of the source code.

The following program calls sapmzts1 and sends the output to the spool system:

Syntax Syntax

  1. REPORT demo_list_submit_to_spool NO STANDARD PAGE HEADING.
  2. DATA: val(1) TYPE c,
  3.       pripar TYPE pri_params,
  4.       arcpar TYPE arc_params.
  5. CALL FUNCTION 'GET_PRINT_PARAMETERS'
  6.      EXPORTING
  7.           layout                 = 'X_65_132'
  8.           line_count             = 65
  9.           line_size              = 132
  10.      IMPORTING
  11.           out_parameters         = pripar
  12.           out_archive_parameters = arcpar
  13.           valid                  = val
  14.      EXCEPTIONS
  15.           archive_info_not_found = 1
  16.           invalid_print_params   = 2
  17.           invalid_archive_params = 3
  18.           OTHERS                 = 4.
  19. IF val <> space AND sy-subrc = 0.
  20.   SUBMIT demo_list_output TO SAP-SPOOL
  21.     SPOOL   PARAMETERS pripar
  22.     ARCHIVE PARAMETERS arcpar
  23.     WITHOUT SPOOL DYNPRO.
  24. ENDIF.
End of the source code.

After starting the program, the function module GET_PRINT_PARAMETERS triggers a user dialog, displaying the area Output format of the Print List Output dialog window filled with the values from the import parameters:

This graphic is explained in the accompanying text.

After the user has entered and confirmed the print parameters, sapmzts1 is called. Here, the GET_PRINT_PARAMETERS export parameters are passed as print and archiving parameters. sapmzts1 does not create any screen display or user dialog. It sends the created list directly to the spool system. The user can view the stored spool request choosing    System   Services   Print requests  . Using the output format specified above, the spool request may look like this:

This graphic is explained in the accompanying text.