Skip to Content
0
Former Member
Aug 08, 2007 at 02:53 PM

When sending email PO in a PDF attachment, the attachment can not be openen

788 Views

Hi all,

We are trying to send an email with the PO in PDF format. We got the email but the attachment can not be opened.

Error reads: Adobe could not open test.pdf because it is either not a supported file type or because the file has been damaged (for example , it was send as a email attachemnet and was not correctly decoded).

Could any body bring some light? We know that everything in SCOT is fine because we can email the PO through configuration to the vendor without problem. It is just these extra copies that do not work.

a) We are modifying our custom Print program to add the code below after closing the form.

in few words:

a) We are getting the OTF from closing the form.

b) Converting the OTF to PDF

c) Sending the PDF as attachment.

data: lt_docs TYPE TABLE OF docs.

data: pdf_bytecount TYPE i.

data: begin of pdfout occurs 0,

tline type tline,

end of pdfout.

  • Ende Formulardruck --------------------------------------------------*

CALL FUNCTION 'CLOSE_FORM'

IMPORTING

result = result

tables

otfdata = otf.

IF RESULT-TDSPOOLID NE SPACE.

SPOOLID = RESULT-TDSPOOLID.

PERFORM PROTOCOL_UPDATE USING '320' SPOOLID SPACE SPACE SPACE.

ENDIF.

if result-userexit eq 'C' or

result-userexit eq 'E'.

retco = '9'.

endif.

CALL FUNCTION 'CONVERT_OTF_2_PDF'

IMPORTING

bin_filesize = pdf_bytecount

TABLES

otf = otf

doctab_archive = lt_docs

lines = pdfout

EXCEPTIONS

err_conv_not_possible = 1

err_otf_mc_noendmarker = 2

OTHERS = 3.

  • Creation of the document to be sent File Name

maildata-obj_name = 'TEST'.

  • Mail Subject

maildata-obj_descr = 'Subject'.

  • Mail Contents

append mailtxt.

describe table mailtxt lines tab_lines.

read table mailtxt index tab_lines.

maildata-doc_size = ( tab_lines - 1 ) * 255 + STRLEN( mailtxt ).

  • Creation of the entry for the compressed document

clear mailpack-transf_bin.

mailpack-head_start = 1.

mailpack-head_num = 0.

mailpack-body_start = 1.

mailpack-body_num = tab_lines.

mailpack-doc_type = 'RAW'.

append mailpack.

  • Move OTF code to structure SOLI form email

  • CLEAR solisti1. REFRESH solisti1.

  • LOOP AT otf.

  • solisti1-line = otf.

  • APPEND solisti1.

  • ENDLOOP.

  • Move pdf code to structure soli form email

clear solisti1. refresh solisti1.

loop at pdfout.

solisti1-line = pdfout.

append solisti1.

endloop.

loop at solisti1.

move-corresponding solisti1 to mailbin.

append mailbin.

endloop.

describe table mailbin lines tab_lines.

  • mailhead = 'TEST.OTF'.

mailhead = 'TEST.PDF'.

append mailhead.

  • Creation of the entry for the compressed attachment

mailpack-transf_bin = 'X'.

mailpack-head_start = 1.

mailpack-head_num = 1.

mailpack-body_start = 1.

mailpack-body_num = tab_lines.

  • mailpack-doc_type = 'OTF'.

mailpack-doc_type = 'PDF'.

mailpack-obj_name = 'TEST'.

mailpack-obj_descr = 'Subject'.

mailpack-doc_size = tab_lines * 255.

append mailpack.

mailrec-receiver = 'lgrimes@ouremail.com'.

mailrec-rec_type = 'U'.

append mailrec.

mailrec-receiver = 'maraoz@ouremail.com'.

mailrec-rec_type = 'U'.

append mailrec.

CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'

EXPORTING

DOCUMENT_DATA = maildata

TABLES

PACKING_LIST = mailpack

OBJECT_HEADER = mailhead

CONTENTS_TXT = mailtxt

RECEIVERS = mailrec

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.

ENDFORM.