Want to download PDF from Spool using ‘CONVERT_ABAPSPOOLJOB_2_PDF’

Hi ABAPers, I want to Download the PDF file using Program which is already generated in the SPOOL, I Tried using the below code

FM CALL FUNCTION ‘CONVERT_ABAPSPOOLJOB_2_PDF’
    EXPORTING
      src_spoolid              = lv_spool_id
      no_dialog                = ‘X’
      dst_device               = ‘PDF1’
      pdf_destination          = ‘X’
    IMPORTING
      pdf_bytecount            = lv_bin_size
      pdf_spoolid              = ev_spoolid
      bin_file                 = lv_xstring
    TABLES
      pdf                      = lta_lt_pdf
    EXCEPTIONS
      err_no_abap_spooljob     = 1
      err_no_spooljob          = 2
      err_no_permission        = 3
      err_conv_not_possible    = 4
      err_bad_destdevice       = 5
      user_cancelled           = 6
      err_spoolerror           = 7
      err_temseerror           = 8
      err_btcjob_open_failed   = 9
      err_btcjob_submit_failed = 10
      err_btcjob_close_failed  = 11
      OTHERS                   = 12.
  IF sy-subrc <> 0.
* Implement suitable error handling here
  ENDIF.
 LTA_LT_PDF internal table is getting not any data from the FM, I can only see the binsize and xstring getting filled up, How to proceed further, Tried to convert xstring to PDF using  

CALL FUNCTION ‘SCMS_XSTRING_TO_BINARY’
    EXPORTING
      buffer     = lv_xstring
    TABLES
      binary_tab = data_tab.
and

CALL FUNCTION ‘GUI_DOWNLOAD’
    EXPORTING
      bin_filesize            = lv_bin_size
      filename                = lv_path
      filetype                = ‘BIN’
    TABLES
      data_tab                = data_tab
    EXCEPTIONS
      file_write_error        = 1
      no_batch                = 2
      gui_refuse_filetransfer = 3
      invalid_type            = 4
      no_authority            = 5
      unknown_error           = 6
      header_not_allowed      = 7
      separator_not_allowed   = 8
      filesize_not_allowed    = 9
      header_too_long         = 10
      dp_error_create         = 11
      dp_error_send           = 12
      dp_error_write          = 13
      unknown_dp_error        = 14
      access_denied           = 15
      dp_out_of_memory        = 16
      disk_full               = 17
      dp_timeout              = 18
      file_not_found          = 19
      dataprovider_exception  = 20
      control_flush_error     = 21
      OTHERS                  = 22.
  IF sy-subrc <> 0.
* Implement suitable error handling here
  ENDIF.

 

But PDF which is getting downloading looks corrupted, What could be the reason? 

 

Scroll to Top