Skip to Content

Multiple PDF attachments to single PDF file

Hi Mr.Abaper's

I'm getting multiple PDF attachments I want to convert into a single pdf.

Regards,

Srinivas

SELECT gjahr belnr FROM ekbe
INTO TABLE it_ekbe
WHERE ebeln = p_ebeln .


LOOP AT it_ekbe INTO it_ekbe_line .

** Concatenate Material Document Number and Year to Instance Id
CONCATENATE it_ekbe_line-belnr
it_ekbe_line-gjahr
INTO lwa_lporb-instid.

** Type of Object
lwa_lporb-typeid = lc_typeid.
** Category Of Object
lwa_lporb-catid = lc_catid.
REFRESH lt_links.
** Call Method to read relationship records for instance(GR)
TRY.
CALL METHOD cl_binary_relation=>read_links_of_binrel
EXPORTING
is_object = lwa_lporb
ip_relation = lc_rel_typ
IMPORTING
et_links = lt_links.

CATCH cx_obl_parameter_error.
CLEAR sy-subrc.
CATCH cx_obl_internal_error.
CLEAR sy-subrc.
CATCH cx_obl_model_error.
CLEAR sy-subrc.
ENDTRY.


IF lt_links[] IS NOT INITIAL.
SORT lt_links BY utctime DESCENDING.

LOOP AT lt_links INTO lwa_links.

REFRESH lt_contents_hex.
** Instance Id in Busness Objects
lv_docid = lwa_links-instid_b.
** Call Function Module to read contents of attached document
CALL FUNCTION 'SO_DOCUMENT_READ_API1'
EXPORTING
document_id = lv_docid
* filter = 'X '
IMPORTING
document_data = lwa_docdata
TABLES
contents_hex = lt_contents_hex
EXCEPTIONS
document_id_not_exist = 1
operation_no_authorization = 2
x_error = 3
OTHERS = 4.
IF sy-subrc EQ 0 AND lt_contents_hex IS NOT INITIAL.
CLEAR: lv_length,
lv_file_content.
DESCRIBE TABLE lt_contents_hex LINES lv_lin.
lv_length = lv_lin * sy-tleng.


CONCATENATE 'C:\Users\BPSH066\Desktop/multitest'
sy-uzeit
'.pdf'
INTO lv_path.

CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
bin_filesize = lv_length
filename = lv_path
filetype = 'BIN'
TABLES
data_tab = lt_contents_hex.
ENDIF.
ENDLOOP.
ENDIF.

ENDLOOP.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • Best Answer
    Posted on Oct 18, 2019 at 12:24 PM

    Please check the standard program "RSPO_TEST_MERGE_PDF_FILES". In the subroutine merge_pdf, class "cl_rspo_pdf_merge" is used to merge multiple PDFs.

    Thanks,

    Gourab

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Oct 17, 2019 at 12:43 PM

    A PDF is not a flat file, if you are running under linux you cannot do cat pdf1 > pdf cat pdf2 >> pdf.

    there is a header, with header information, there is global definition ....

    so merging pdf need a dedicated application

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.