Application Development 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: 

Merging multiple spools into a single PDF to attach workflow

Former Member
0 Kudos

Dear Experts,

I have a requirement to merge multiple spools into a single PDF and attaching this final pdf to a workflow work item for approval.

Below is the process I followed for 3 spools conversion

1) ‘CONVERT_ABAPSPOOLJOB_2_PDF’ – To convert spool into PDF format

2) SX_TABLE_LINE_WIDTH_CHANGE – To Change the line width

3) SCMS_BINARY_TO_XSTRING – To Convert Binary to XSTRING format

4) SCMS_XSTRING_TO_BINARY – To convert XSTRING to Binary

5) Appended 3 internal tables data to single internal table and passing the final internal table to

method cl_gui_frontend_services=>gui_download.

I wrote the below code to to merge 3 spools into single pdf, program could able to generate a pdf but showing only single spool(First spool) .

Where I am missing??????? Could you please help us in complete the requirement.

Thanks in advance.

REPORT ZSPOOL.
PARAMETERS e_spool TYPE rspoid.
PARAMETERS e_spool1 TYPE rspoid.
PARAMETERS e_spool2 TYPE rspoid.
*PERFORM ali_spool_generator
* CHANGING
* e_spool.
DATA et_pdf TYPE tline_tab.
DATA et_pdf1 TYPE tline_tab.
DATA et_pdf2 TYPE tline_tab.
DATA e_binary_length TYPE i.
DATA e_binary_length1 TYPE i.
DATA e_binary_length2 TYPE i.
PERFORM convert_ali_spool_to_pdf
USING
e_spool
CHANGING
et_pdf
e_binary_length.
PERFORM convert_ali_spool_to_pdf
USING
e_spool1
CHANGING
et_pdf1
e_binary_length1.
PERFORM convert_ali_spool_to_pdf
USING
e_spool2
CHANGING
et_pdf2
e_binary_length2.
data SOLI_TAB type SOLI_TAB.
data SOLI_TAB1 type SOLI_TAB.
data SOLI_TAB2 type SOLI_TAB.
CALL FUNCTION ‘SX_TABLE_LINE_WIDTH_CHANGE’
TABLES
content_in = et_pdf
content_out = SOLI_TAB
EXCEPTIONS
OTHERS = 4.
CALL FUNCTION ‘SX_TABLE_LINE_WIDTH_CHANGE’
TABLES
content_in = et_pdf1
content_out = SOLI_TAB1
EXCEPTIONS
OTHERS = 4.

CALL FUNCTION ‘SX_TABLE_LINE_WIDTH_CHANGE’
TABLES
content_in = et_pdf2
content_out = SOLI_TAB2
EXCEPTIONS
OTHERS = 4.

data e_xstring TYPE xstring.
data e_xstring1 TYPE xstring.
data e_xstring2 TYPE xstring.
CALL FUNCTION ‘SCMS_BINARY_TO_XSTRING’
EXPORTING
input_length = e_binary_length
IMPORTING
buffer = e_xstring
TABLES
binary_tab = SOLI_TAB
EXCEPTIONS
OTHERS = 2.
CALL FUNCTION ‘SCMS_BINARY_TO_XSTRING’
EXPORTING
input_length = e_binary_length1
IMPORTING
buffer = e_xstring1
TABLES
binary_tab = SOLI_TAB1
EXCEPTIONS
OTHERS = 2.

CALL FUNCTION ‘SCMS_BINARY_TO_XSTRING’
EXPORTING
input_length = e_binary_length2
IMPORTING
buffer = e_xstring2
TABLES
binary_tab = SOLI_TAB2
EXCEPTIONS
OTHERS = 2.

DATA lt_solix TYPE solix_tab.
DATA lt_solix1 TYPE solix_tab.
DATA lt_solix2 TYPE solix_tab.
CALL FUNCTION ‘SCMS_XSTRING_TO_BINARY’
EXPORTING
buffer = e_xstring
TABLES
binary_tab = lt_solix.
CALL FUNCTION ‘SCMS_XSTRING_TO_BINARY’
EXPORTING
buffer = e_xstring1
TABLES
binary_tab = lt_solix1.

CALL FUNCTION ‘SCMS_XSTRING_TO_BINARY’
EXPORTING
buffer = e_xstring2
TABLES
binary_tab = lt_solix2.

append LINES OF lt_solix1 to lt_solix.
append LINES OF lt_solix2 to lt_solix.

* REPLACE THAT BY YOUR CODE TO SEND MAIL
CALL METHOD cl_gui_frontend_services=>gui_download
EXPORTING
bin_filesize = e_binary_length
filename = `C:\Users\ffffffffff.pdf`
filetype = ‘BIN’
CHANGING
data_tab = lt_solix
EXCEPTIONS
OTHERS = 3.
* <<<<<<<<<<<<<<

FORM ali_spool_generator
CHANGING
e_spoolid TYPE rspoid.
* NEW-PAGE PRINT ON NO DIALOG.
* WRITE : / ‘Hello World’.
* NEW-PAGE PRINT OFF.
* e_spoolid = sy-spono.
* COMMIT WORK.
ENDFORM.

FORM convert_ali_spool_to_pdf
USING
i_spoolid TYPE rspoid
CHANGING
et_pdf TYPE tline_tab
e_binary_length TYPE i.
CALL FUNCTION ‘CONVERT_ABAPSPOOLJOB_2_PDF’
EXPORTING
src_spoolid = i_spoolid
no_dialog = ‘X’
IMPORTING
pdf_bytecount = e_binary_length
TABLES
pdf = et_pdf
EXCEPTIONS
OTHERS = 12.
ENDFORM.

2 REPLIES 2

Sandra_Rossi
Active Contributor
0 Kudos

It's been asked several times how to merge spools into one pdf. Please search the forum.

VijayCR
Active Contributor
0 Kudos

call the below FM in a loop three times if you want to create three spools and the later merge into PDF.

FORM convert_ali_spool_to_pdf
USING
i_spoolid TYPE rspoid
CHANGING
et_pdf TYPE tline_tab
e_binary_length TYPE i.