Skip to end of metadata
Go to start of metadata

The following program shows how to generate spools in dialog (no need to submit the program in background).
It creates 2 spools, converts them to PDF files, and downloads them to C: directory on frontend computer.

REPORT z.
DATA l_file_name TYPE string.
DATA l_spoolid TYPE i.
DATA l_size_bytes TYPE i.
DATA lt_lines TYPE TABLE OF tline.
DATA: ls_pripar TYPE pri_params,
      ls_arcpar TYPE arc_params.
CALL FUNCTION 'GET_PRINT_PARAMETERS'
  IMPORTING
    out_parameters         = ls_pripar
    out_archive_parameters = ls_arcpar
  EXCEPTIONS
    archive_info_not_found = 1
    invalid_print_params   = 2
    invalid_archive_params = 3
    OTHERS                 = 4.
DO 2 TIMES.

  NEW-PAGE PRINT ON
    NEW-SECTION
    PARAMETERS ls_pripar
    ARCHIVE PARAMETERS ls_arcpar
    NO DIALOG.
  WRITE / 'Current spool number:'.
  l_spoolid = sy-spono.
  WRITE l_spoolid.
  DO 10 TIMES.
    WRITE / sy-index.
  ENDDO.
  NEW-PAGE PRINT OFF.

  CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'
    EXPORTING
      src_spoolid   = l_spoolid
      no_dialog     = 'X'
    IMPORTING
      pdf_bytecount = l_size_bytes
    TABLES
      pdf           = lt_lines
    EXCEPTIONS
      OTHERS        = 12.
  CONCATENATE 'c:/' sy-spono '.pdf' INTO l_file_name.
  CALL METHOD cl_gui_frontend_services=>gui_download
    EXPORTING
      bin_filesize = l_size_bytes
      filename     = l_file_name
      filetype     = 'BIN'
    CHANGING
      data_tab     = lt_lines
    EXCEPTIONS
      OTHERS       = 24.
ENDDO.