05-23-2016 10:35 AM
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!
05-24-2016 4:29 PM
Maybe you could output all the abap list spool files to a new spool file, and you can then convert it into a PDF.
To output every spool file, you must do it in 4 steps:
SUBMIT rspolst2
WITH RQIDENT = l_rqident "spool number
EXPORTING LIST TO MEMORY
AND RETURN.
CALL FUNCTION 'LIST_FROM_MEMORY'
TABLES
listobject = lt_listobject
EXCEPTIONS
not_found = 1
OTHERS = 2.
CALL FUNCTION 'WRITE_LIST'
TABLES
listobject = lt_listobject
EXCEPTIONS
empty_list = 1
OTHERS = 2.
Repeat until all spool files are processed.
05-23-2016 10:47 AM
I would imagine you should merge the spools before converting to PDF.
05-23-2016 10:56 AM
I guess there should be also an other solution.
if not...do you have some snippet oder Approach for mixing?
Thank you
05-23-2016 10:54 AM
05-23-2016 11:15 AM
Thank you Maria.
Nice one.
Hopefully i'm able to solve it in the way to merga basisdata at first. Than converting to PDF.
Than there is not need for PDFTK.
Thank you
05-23-2016 11:26 AM
Please explain more in details, so that another guy can find your answer, and close the thread. Thanks.
05-23-2016 11:41 AM
Hi,
Hope this helps:
there are 2 forms:
abap_to_pdf
spool_to_pedf
form abap_to_pdf .
clear it_pdf[].
call function 'CONVERT_ABAPSPOOLJOB_2_PDF'
exporting
src_spoolid = p_rqid
tables
pdf = it_pdf.
if p_fic = 'X'.
open dataset p_fich for output in binary mode.
if sy-subrc is initial.
loop at it_pdf into wa_pdf.
transfer wa_pdf to p_fich.
endloop.
close dataset p_fich.
if p_abrir = 'X'.
call function 'WS_EXECUTE'
exporting
document = 'X'
program = p_fich.
endif.
else.
message e000 with 'Erro na abertura do ficheiro' sy-subrc.
endif.
endif.
if p_mem = 'X'.
export it_pdf to memory id p_memid.
endif.
endform. " ABAP_TO_PDF
*&---------------------------------------------------------------------*
*& Form OTF_TO_PDF
*&---------------------------------------------------------------------*
form otf_to_pdf .
call function 'CONVERT_OTFSPOOLJOB_2_PDF'
exporting
src_spoolid = p_rqid
tables
pdf = it_pdf.
if p_fic = 'X'.
open dataset p_fich for output in binary mode.
if sy-subrc is initial.
loop at it_pdf into wa_pdf.
transfer wa_pdf to p_fich.
endloop.
close dataset p_fich.
if p_abrir = 'X'.
call function 'WS_EXECUTE'
exporting
document = 'X'
program = p_fich.
endif.
else.
message e000 with 'Erro na abertura do ficheiro' sy-subrc.
endif.
endif.
if p_mem = 'X'.
export it_pdf to memory id p_memid.
endif.
endform. " OTF_TO_PDF
Regards,
Maria João Rocha
05-23-2016 11:53 AM
05-23-2016 11:57 AM
Thank you Maria.
I know these FM's.
Does your solution also support
2 abap list-spools (no OTF!!) -> 1 PDF?
I was only able to set 1 spool to 1 pdf.
05-23-2016 12:02 PM
Hi,
As i said we use the pdf merge solution:
The zca_spool_to_pdf program is essentialy for the code in my post obove.
This merge several lists...
...
form merge_pdf.
field-symbols: <l_xline> type x.
create object pdfmerge.
clear pdf.
loop at it_rqid into wa_rqid.
clear: it_pdf[].
submit zca_spool_to_pdf with p_rqid = wa_rqid-rqident
with p_mem = 'X'
with p_memid = 'MERGEPDF'
with p_fich = p_fich
and return.
import it_pdf
from memory id 'MERGEPDF'.
loop at it_pdf into wa_pdf.
assign wa_pdf to <l_xline> casting.
concatenate pdf <l_xline> into pdf in byte mode.
endloop.
pdfmerge->add_pdf( pdf ).
endloop.
pdfmerged = pdfmerge->get_merged( ).
if p_memid is initial.
open dataset p_fich for output in binary mode.
transfer pdfmerged to p_fich.
close dataset p_fich.
call function 'WS_EXECUTE'
exporting
document = 'X'
program = p_fich.
else.
export pdfmerged to memory id 'ZCA_MERGE_PDF'.
endif.
endform. " MERGE_PDF
Regards,
Maria João Rocha
05-24-2016 4:29 PM
Maybe you could output all the abap list spool files to a new spool file, and you can then convert it into a PDF.
To output every spool file, you must do it in 4 steps:
SUBMIT rspolst2
WITH RQIDENT = l_rqident "spool number
EXPORTING LIST TO MEMORY
AND RETURN.
CALL FUNCTION 'LIST_FROM_MEMORY'
TABLES
listobject = lt_listobject
EXCEPTIONS
not_found = 1
OTHERS = 2.
CALL FUNCTION 'WRITE_LIST'
TABLES
listobject = lt_listobject
EXCEPTIONS
empty_list = 1
OTHERS = 2.
Repeat until all spool files are processed.
05-25-2016 1:38 PM
02-09-2022 9:21 AM