Вы находитесь на странице: 1из 7

1. * Get FP reference.

2. l_fp = cl_fp=>get_reference( ).
3.
4. TRY.
5. * Create PDF Object.
6. l_pdfobj = l_fp->create_pdf_object( connection = p_dest ).
7.
8. * Set document.
9. l_pdfobj->set_document( pdfdata = l_pdf ).
10.
11. * Set attachment.
12. CONCATENATE 'Attachment' sy-uzeit INTO l_attachment-name
13. SEPARATED BY space. "#EC NOTEXT
14. l_filename = p_att.
15. CALL FUNCTION 'SPLIT_FILENAME'
16. EXPORTING
17. long_filename = l_filename
18. IMPORTING
19. pure_filename = l_short
20. pure_extension = l_ext.
21. CONCATENATE l_short l_ext INTO l_attachment-filename
22. SEPARATED BY '.'.
23. CALL FUNCTION 'SKWF_MIMETYPE_OF_FILE_GET'
24. EXPORTING
25. filename = l_filename
26. IMPORTING
27. mimetype = l_mimetype.
28. l_attachment-mimetype = l_mimetype.
29. l_attachment-description = l_attachment-name.
30. l_attachment-data = l_att.
31. INSERT l_attachment INTO TABLE l_attachments.
32. l_pdfobj->set_attachments( attachments = l_attachments ).
33.
34. * Execute, call ADS.
35. l_pdfobj->execute( ).
36.
37. * Get result.
38. l_pdfobj->get_document( IMPORTING pdfdata = l_pdf ).
39.
40. CATCH cx_fp_runtime_internal
41. cx_fp_runtime_system
42. cx_fp_runtime_usage INTO l_fpex.
43. PERFORM error USING l_fpex.
44. ENDTRY.

==================================================================================
=

LOOP AT it_header INTO wa_header.

REFRESH it_item1.

CLEAR:wa_item.

LOOP AT it_item INTO wa_item WHERE dc_no = wa_header-dc_no.

APPEND wa_item TO it_item1.

CLEAR wa_item.

ENDLOOP.

CALL FUNCTION lv_fname

EXPORTING

control_parameters = st_control_parameters

output_options = st_output_options

user_settings = ' '

wa_header = wa_header

IMPORTING

document_output_info = st_document_output_info

job_output_info = st_job_output_info

job_output_options = st_job_output_options
TABLES

it_item = it_item1

EXCEPTIONS

formatting_error = 1

internal_error = 2

send_error = 3

user_canceled = 4

OTHERS = 5.

IF sy-subrc NE 0.

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

CLEAR wa_pdf.

LOOP AT st_job_output_info-otfdata INTO wa_pdf.

APPEND wa_pdf TO it_pdf.

ENDLOOP.

CLEAR wa_header.

ENDLOOP.

CALL FUNCTION 'CONVERT_OTF_2_PDF'

IMPORTING

bin_filesize = v_bin_filesize

TABLES

otf = it_pdf

doctab_archive = it_docs

lines = it_lines

EXCEPTIONS

err_conv_not_possible = 1

err_otf_mc_noendmarker = 2

OTHERS = 3.

IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

CALL FUNCTION 'SSFCOMP_PDF_PREVIEW'

EXPORTING

i_otf = it_pdf

EXCEPTIONS

convert_otf_to_pdf_error = 1

cntl_error = 2

OTHERS = 3.

IF sy-subrc <> 0.

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

CONCATENATE 'REJECTION' '-' 'RETURN' '.pdf' INTO v_name.

CREATE OBJECT v_guiobj.

CALL METHOD v_guiobj->file_save_dialog

EXPORTING

default_extension = 'pdf'

default_file_name = v_name

file_filter = v_filter

CHANGING

filename = v_name

path = v_path

fullpath = v_fullpath

user_action = v_uact.

IF v_uact = v_guiobj->action_cancel.

EXIT.

ENDIF.
found one you can download to your PC as a PDF.

But you need to convert PDF to binary both files and append each then convert pdf download in
local drive.

report zfile_access.

data : g_path(128),

t_path type string.

data : begin of gt_lines occurs 0,

line type x,

end of gt_lines.

data : lt_value like tline occurs 0 with header line.

g_path = 'P:\FEMS_ABC\2850_specs.pdf'.

t_path = 'c:\temp\2850_specs.pdf'.

open dataset g_path for input in binary mode.

if sy-subrc = 0.

clear : lt_value.

refresh : lt_value.

do.

read dataset g_path into gt_lines-line.

if sy-subrc = 0.

append gt_lines.

else.

exit.

endif.

enddo.

endif.

close dataset g_path.

you append both binary files in gt_lines and download to t_path(.pdf) it will show nice pdf format.

call function 'GUI_DOWNLOAD'

exporting

filename = t_path

filetype = 'BIN'
tables

data_tab = gt_lines

Former Member
September 27, 2016 1 minute read

Merging/Combining mulitiple PDF spool into


single one
Follow RSS feed Like
1 Like 1,949 View 1 Comment

Hi all,
I am sharing my new development scenario.
Scenario:
Multiple documents are being printed at the Shipment Complete step. This process happens many times a day and
for more than 1 Shipment at a time. If all these documents print at the same time, a user will need to sort through all
the documents and figure out which print goes with which shipment.

Solution:
For this issue four FM’s are used.

1. RSPO_RETURN_SPOOLJOB

2. RSPO_SR_OPEN

3. RSPO_SR_TABLE_WRITE

4. RSPO_SR_CLOSE

Detailed:

 Read spool data using RSPO_RETURN_SPOOLJOB which takes spool job id


as input and gives data in table which is type of SOLI (SAPoffice: line,
length 255) and append these records to final table which contains
merged data which is type of ITCOO OTF Structure.
 Create one new spool using FM RSPO_SR_OPEN by passing printing
parameters and it’s create one new spool id and handle no.
 Write merged data into newly created spool job using
RSPO_SR_TABLE_WRITE by passing handle no as input and merged data
of type OTF.
 Close the spool job after writing data into it by using FM RSPO_SR_CLOSE.

Вам также может понравиться