Skip to Content
0
Oct 17, 2019 at 12:36 PM

Multiple PDF attachments to single PDF file

176 Views

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.