Skip to Content
0
May 23, 2016 at 09:35 AM

How to merge different abap-list spools, xstrings or binary files to one PDF

1465 Views

Hi out there,

i'm not able to solve my approach. And i#m not able to find any clearly answers by searching different boards.

So...

I'm reading some abap-list spools (NO OTF!!) and i want to merge the content into one PDF document. With OTF it's no prob.

But it#s difficult to solve with abap-spool-list.

So after unsucsessfully approaches via RSPO_RETURN_SPOOLJOB or CONVERT_ABAPSPOOLJOB_2_PDF' I'm now on this:

select * from tsp01 into i_tsp01where rqident in spool.
   append i_tsp01.
endselect.

 data :
           l_file type  xstring,
           l_size type  i,
           lt_file_tab type table of x255,
           lt_file_tab_final type table of x255.

loop at i_tsp01.
   clear: tab1, eof.
   refresh pdf.
clear: l_file, l_size.
call function 'FCC2_SPOOL_TO_PDF'
   exporting
     i_spoolid               = i_tsp01-rqident
  importing
    e_file                  = l_file
    e_size                  = l_size
  exceptions
    spool_not_exist         = 1
    cannot_create_pdf       = 2
    others                  = 3.

call function 'SCMS_XSTRING_TO_BINARY'
   exporting
     buffer                = l_file
    append_to_table       = ''
* IMPORTING
*   OUTPUT_LENGTH         =
   tables
     binary_tab            =  lt_file_tab   .

append lines of lt_file_tab  to lt_file_tab_final.

endloop. call method cl_gui_frontend_services=>gui_download exporting filename = file filetype = 'BIN' changing data_tab = lt_file_tab_final 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 ne 0. write sy-subrc. endif.

With one spool id: OK!

With two spool ids: Only the last spool-content is shown in pdf. Even the pdf is doubled sized the before. Just the last content.

Any Idea? Thank you!