Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Problem in converting spool to PDF file

Former Member
0 Likes
774

Hi guys,

My spool contains Russian characters which are shown as one special char in pdf file. I guess the russian char. are not recognized by pdf.

I convert the spool to pdf using following FM

CALL FUNCTION 'CONVERT_OTFSPOOLJOB_2_PDF'

EXPORTING

src_spoolid = wa_spool-spool

no_dialog = ' '

IMPORTING

pdf_bytecount = v_numbytes

pdf_spoolid = v_pdfspoolid

btc_jobname = v_jobname

btc_jobcount = v_jobcount

TABLES

pdf = pdf.

Then i download the file using FM:

CALL FUNCTION 'WS_DOWNLOAD'

EXPORTING

bin_filesize = v_numbytes

filename = v_return1

filetype = 'BIN'

TABLES

data_tab = pdf

Help me....

Point will be rewarded on helpful answers.

Regards,

GURU

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
559

HI

use my code

it will do the entire job

*&---------------------------------------------------------------------*
*& Report  Z8VM_SPOOL2PDF                                              *
*&                                                                     *
*&---------------------------------------------------------------------*
*&                                                                     *
*&                                                                     *
*&---------------------------------------------------------------------*

report  z8vm_spool2pdf                          .


**-------------------------------------------------------------------**
**---- Author     :    vivekanand meghmala
**---- Purpose    :    Create Single PDF file with outputs of
**----                 Multiple Spools.
**---- Create Date:    July 05th, 2006
**---- Analyst    :    Vivek Maheshwari
**-------------------------------------------------------------------**

**---- Tables
tables : tsp01.

**---- Select Options for Multiple spools
select-options :
  s_spool for tsp01-rqident obligatory.

**---- Parameters for File Path.
parameters :
p_file type localfile default 'C:combined.pdf' obligatory.

**---- Get the Spool Requests entered in Select-options for Spools.
data : i_tsp01 like tsp01 occurs 0 with header line.

**---- Work Areas and Variables
data:  wa_eof type soli,            "----- End of File Work Area
       v_file type string,          "----- String
       v_size type i,               "----- Size
       v_lines type i.              "----- Lines in Internal Table

**---- Internal Table for Spool Details and PDF and Document Details
data : i_spool_table type table of soli,
       i_spool_total type table of soli  with header line,
       i_otf         type table of itcoo with header line,
       i_doc         like table of docs,
       i_pdf         like table of tline.

**---- Move File name to Variable
v_file = p_file.

**---- Clear and Refresh Internal Tables before first use
clear i_tsp01.            refresh i_tsp01.
clear i_spool_table.      refresh i_spool_table.
clear i_spool_total.      refresh i_spool_total.

**---- Get Spool ID Details from TSP01
select * from tsp01 into table i_tsp01 where rqident in s_spool.

**---- Sort Table in Ascending order based on Spool Id
sort i_tsp01 by rqident.

**---- Get information about Multiple spools
loop at i_tsp01.

**---- Get Multiple Spool information
  call function 'RSPO_RETURN_SPOOLJOB'
    exporting
      rqident              = i_tsp01-rqident
    tables
      buffer               = i_spool_table
    exceptions
      no_such_job          = 1
      job_contains_no_data = 2
      selection_empty      = 3
      no_permission        = 4
      can_not_access       = 5
      read_error           = 6
      type_no_match        = 7
      others               = 8.
  if sy-subrc = 0.
  endif.

**---- Get the Last line index (Number of Lines)
  describe table i_spool_table lines v_lines.

**---- Clear Work Area for End of File (EOF) and read
**---- End of File String into it and Delete it
  clear wa_eof.
  read table i_spool_table index v_lines into wa_eof.
  delete i_spool_table index v_lines.

**---- Collect All individual Spool Details into one internal table.
  append lines of i_spool_table to i_spool_total.

  at last.
**---- Append End of File information to Internal table
**---- Containing information about all the invidual spools -
**---- Thus forming one single spool
    append wa_eof to i_spool_total.
  endat.

endloop.

**---- Clear OTF tables before initial use
clear i_otf. refresh i_otf.

**---- Fill in the OTF internal table
loop at i_spool_total.
  clear i_otf.
  i_otf = i_spool_total.
  append i_otf.
endloop.

**---- Convert the OTF information to PDF.
call function 'CONVERT_OTF_2_PDF'
  exporting
    use_otf_mc_cmd         = 'X'
  importing
    bin_filesize           = v_size
  tables
    otf                    = i_otf
    doctab_archive         = i_doc
    lines                  = i_pdf
  exceptions
    err_conv_not_possible  = 1
    err_otf_mc_noendmarker = 2
    others                 = 3.
if sy-subrc <> 0.
  message i002(sy) with 'Cannot convert to PDF, exiting....'.
  leave program.
endif.

          .

**---- Download PDF file thus formed onto frontend
call method cl_gui_frontend_services=>gui_download
  exporting
    filename                = v_file
    filetype                = 'BIN'
  changing
    data_tab                = i_pdf
  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
    not_supported_by_gui    = 22
    error_no_gui            = 23
    others                  = 24.
if sy-subrc <> 0.
  message i002(sy) with 'Cannot download PDF, exiting....'.
  leave program.
endif.

Hi guys,

My spool contains Russian characters which are shown as one special char in pdf file. I guess the russian char. are not recognized by pdf.

I convert the spool to pdf using following FM

CALL FUNCTION 'CONVERT_OTFSPOOLJOB_2_PDF'

EXPORTING

src_spoolid = wa_spool-spool

no_dialog = ' '

IMPORTING

pdf_bytecount = v_numbytes

pdf_spoolid = v_pdfspoolid

btc_jobname = v_jobname

btc_jobcount = v_jobcount

TABLES

pdf = pdf.

Then i download the file using FM:

CALL FUNCTION 'WS_DOWNLOAD'

EXPORTING

bin_filesize = v_numbytes

filename = v_return1

filetype = 'BIN'

TABLES

data_tab = pdf

Help me....

Point will be rewarded on helpful answers.

Regards,

GURU

1 REPLY 1
Read only

Former Member
0 Likes
560

HI

use my code

it will do the entire job

*&---------------------------------------------------------------------*
*& Report  Z8VM_SPOOL2PDF                                              *
*&                                                                     *
*&---------------------------------------------------------------------*
*&                                                                     *
*&                                                                     *
*&---------------------------------------------------------------------*

report  z8vm_spool2pdf                          .


**-------------------------------------------------------------------**
**---- Author     :    vivekanand meghmala
**---- Purpose    :    Create Single PDF file with outputs of
**----                 Multiple Spools.
**---- Create Date:    July 05th, 2006
**---- Analyst    :    Vivek Maheshwari
**-------------------------------------------------------------------**

**---- Tables
tables : tsp01.

**---- Select Options for Multiple spools
select-options :
  s_spool for tsp01-rqident obligatory.

**---- Parameters for File Path.
parameters :
p_file type localfile default 'C:combined.pdf' obligatory.

**---- Get the Spool Requests entered in Select-options for Spools.
data : i_tsp01 like tsp01 occurs 0 with header line.

**---- Work Areas and Variables
data:  wa_eof type soli,            "----- End of File Work Area
       v_file type string,          "----- String
       v_size type i,               "----- Size
       v_lines type i.              "----- Lines in Internal Table

**---- Internal Table for Spool Details and PDF and Document Details
data : i_spool_table type table of soli,
       i_spool_total type table of soli  with header line,
       i_otf         type table of itcoo with header line,
       i_doc         like table of docs,
       i_pdf         like table of tline.

**---- Move File name to Variable
v_file = p_file.

**---- Clear and Refresh Internal Tables before first use
clear i_tsp01.            refresh i_tsp01.
clear i_spool_table.      refresh i_spool_table.
clear i_spool_total.      refresh i_spool_total.

**---- Get Spool ID Details from TSP01
select * from tsp01 into table i_tsp01 where rqident in s_spool.

**---- Sort Table in Ascending order based on Spool Id
sort i_tsp01 by rqident.

**---- Get information about Multiple spools
loop at i_tsp01.

**---- Get Multiple Spool information
  call function 'RSPO_RETURN_SPOOLJOB'
    exporting
      rqident              = i_tsp01-rqident
    tables
      buffer               = i_spool_table
    exceptions
      no_such_job          = 1
      job_contains_no_data = 2
      selection_empty      = 3
      no_permission        = 4
      can_not_access       = 5
      read_error           = 6
      type_no_match        = 7
      others               = 8.
  if sy-subrc = 0.
  endif.

**---- Get the Last line index (Number of Lines)
  describe table i_spool_table lines v_lines.

**---- Clear Work Area for End of File (EOF) and read
**---- End of File String into it and Delete it
  clear wa_eof.
  read table i_spool_table index v_lines into wa_eof.
  delete i_spool_table index v_lines.

**---- Collect All individual Spool Details into one internal table.
  append lines of i_spool_table to i_spool_total.

  at last.
**---- Append End of File information to Internal table
**---- Containing information about all the invidual spools -
**---- Thus forming one single spool
    append wa_eof to i_spool_total.
  endat.

endloop.

**---- Clear OTF tables before initial use
clear i_otf. refresh i_otf.

**---- Fill in the OTF internal table
loop at i_spool_total.
  clear i_otf.
  i_otf = i_spool_total.
  append i_otf.
endloop.

**---- Convert the OTF information to PDF.
call function 'CONVERT_OTF_2_PDF'
  exporting
    use_otf_mc_cmd         = 'X'
  importing
    bin_filesize           = v_size
  tables
    otf                    = i_otf
    doctab_archive         = i_doc
    lines                  = i_pdf
  exceptions
    err_conv_not_possible  = 1
    err_otf_mc_noendmarker = 2
    others                 = 3.
if sy-subrc <> 0.
  message i002(sy) with 'Cannot convert to PDF, exiting....'.
  leave program.
endif.

          .

**---- Download PDF file thus formed onto frontend
call method cl_gui_frontend_services=>gui_download
  exporting
    filename                = v_file
    filetype                = 'BIN'
  changing
    data_tab                = i_pdf
  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
    not_supported_by_gui    = 22
    error_no_gui            = 23
    others                  = 24.
if sy-subrc <> 0.
  message i002(sy) with 'Cannot download PDF, exiting....'.
  leave program.
endif.