Printing Lists from a Called Program 

Druckparameter

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

Syntax

SUBMIT <rep> TO SAP-SPOOL
             [<params>|SPOOL PARAMETERS <pripar>]
             [ARCHIVE PARAMETERS <arcpar>]
             [WITHOUT SPOOL DYNPRO].

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

The same applies to setting the print parameters as described for the NEW-PAGE PRINT ON statement (see Printing from within the Program).

Although you can set each print parameter individually using one of the <params> additions (refer to the keyword documentation ), or by using a user dialog in the SUBMIT statement, you should only retrieve the parameters using the function module GET_PRINT_PARAMETERS. (For further information, refer to Setting Print Parameters from within the Program). 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 options SPOOL PARAMETERS and ARCHIVE PARAMETERS and, to suppress the user dialog of the SUBMIT statement, use the WITHOUT SPOOL DYNPRO option.

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

REPORT SAPMZTS1.

TABLES SPFLI.

GET SPFLI.

  NEW-LINE.
  WRITE: SPFLI-MANDT, SPFLI-CARRID, SPFLI-CONNID,
  SPFLI-CITYFROM, SPFLI-AIRPFROM, SPFLI-CITYTO,
  SPFLI-AIRPTO, SPFLI-FLTIME, SPFLI-DEPTIME, SPFLI-ARRTIME,
  SPFLI-DISTANCE, SPFLI-DISTID, SPFLI-FLTYPE.

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

REPORT SAPMZTST NO STANDARD PAGE HEADING.

DATA: VAL,
      PRIPAR LIKE PRI_PARAMS,
      ARCPAR LIKE ARC_PARAMS.

CALL FUNCTION 'GET_PRINT_PARAMETERS'
      EXPORTING
          LAYOUT                 = 'X_65_132'
          LINE_COUNT             = 65
          LINE_SIZE              = 132
     IMPORTING
          OUT_PARAMETERS         = PRIPAR
          OUT_ARCHIVE_PARAMETERS = ARCPAR
          VALID                  = VAL
     EXCEPTIONS
          ARCHIVE_INFO_NOT_FOUND = 1
          INVALID_PRINT_PARAMS   = 2
          INVALID_ARCHIVE_PARAMS = 3
          OTHERS                 = 4.

IF VAL <> SPACE AND SY-SUBRC = 0.
  SUBMIT SAPMZTS1 TO SAP-SPOOL
    SPOOL   PARAMETERS PRIPAR
    ARCHIVE PARAMETERS ARCPAR
    WITHOUT SPOOL DYNPRO.
ENDIF.

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:

After the user has entered and confirmed the print parameters, SAPMZTS1 is called. In the call, the export parameters of GET_PRINT_PARAMETERS are passed as print and archiving parameters. SAPMZTS1 creates neither a screen display nor a 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: