Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

PDF Attachment Email Opening issue in 4.6c

Hi,

We are having problem with sending pdf attachment. I'm able to send emails as PDF attachments , but the attached PDF file wont open. I'm getting a message "Adobe reader could not open attachement the file has been damaged".

once after writing my list to spool then i am using

CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'

EXPORTING

src_spoolid = gd_spool_nr

no_dialog = c_no

dst_device = c_device

IMPORTING

pdf_bytecount = gd_bytecount

TABLES

pdf = it_pdf_output

EXCEPTIONS

err_no_abap_spooljob = 1

err_no_spooljob = 2

err_no_permission = 3

err_conv_not_possible = 4

err_bad_destdevice = 5

user_cancelled = 6

err_spoolerror = 7

err_temseerror = 8

err_btcjob_open_failed = 9

err_btcjob_submit_failed = 10

err_btcjob_close_failed = 11

OTHERS = 12.

LOOP AT it_pdf_output.

TRANSLATE it_pdf_output USING ' ~'.

CONCATENATE gd_buffer it_pdf_output INTO gd_buffer.

ENDLOOP.

TRANSLATE gd_buffer USING '~ '.

DO.

it_attach = gd_buffer.

APPEND it_attach.

SHIFT gd_buffer LEFT BY 255 PLACES.

IF gd_buffer IS INITIAL.

EXIT.

ENDIF.

ENDDO.

and then, i am populating structure values like

CLEAR ls_doc_head.

ls_doc_head-obj_langu = sy-langu.

ls_doc_head-obj_name = 'SAPRPT'.

ls_doc_head-obj_descr = esubject.

ls_doc_head-sensitivty = 'F'.

READ TABLE it_attach INDEX gv_cnt.

ls_doc_head-doc_size =

( gv_cnt - 1 ) * 255 + STRLEN( it_attach ).

it_packlist-transf_bin = space.

it_packlist-head_start = 1.

it_packlist-head_num = 0.

it_packlist-body_start = 1.

DESCRIBE TABLE it_message LINES it_packlist-body_num.

it_packlist-doc_type = 'RAW'.

APPEND it_packlist.

  • Create attachment notification

it_packlist-transf_bin = 'X'.

it_packlist-head_start = 1.

it_packlist-head_num = 1.

it_packlist-body_start = 1.

DESCRIBE TABLE it_attach LINES it_packlist-body_num.

it_packlist-doc_type = 'PDF'.

it_packlist-obj_descr = ''.

it_packlist-obj_name = 'Attachment'.

it_packlist-doc_size = it_packlist-body_num * 255.

APPEND it_packlist.

finally i am calling below function module

CALL FUNCTION 'SO_DOCUMENT_SEND_API1'

EXPORTING

document_data = ls_doc_head

put_in_outbox = 'X'

sender_address = ''

sender_address_type = ''

commit_work = 'X'

IMPORTING

sent_to_all = gv_sentall

TABLES

packing_list = it_packlist

contents_bin = it_attach

contents_txt = it_message

receivers = it_receivers

EXCEPTIONS

too_many_receivers = 1

document_not_sent = 2

document_type_not_exist = 3

operation_no_authorization = 4

parameter_error = 5

x_error = 6

enqueue_error = 7

OTHERS = 8.

its working fine and i am able to receive pdf document. but when i am trying to open the file

its saying

Adobe reader could not open attachement the file has been damaged

Any help could be appriciated

Thanks,

Sara

Tags:
Former Member
Not what you were looking for? View more on this topic or Ask a question