cancel
Showing results for 
Search instead for 
Did you mean: 

Error while opening PDF in mail attachment

Former Member
0 Kudos

Hi All,

In smartform i am sending a mail with attachemnt as PDF file,there is one more option like preview of smartform .

issue is like i am able to see the preview of the same record but when it is sent in mail attachement,and while opening PDF its showing error that file can not be open it is corrupted.

Please help.

Mona Singh.

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hello. I have exactly the same problem. I return the OTF data from the Smartform and call the function CONVERT_OTF.

If I now do a GUI_DOWNLOAD, I can open the PDF file as expected, but when I send the file as an attachment in an e-mail (using f.m. SO_NEW_DOCUMENT_ATT_SEND_API1) I cannot open the PDF file. Instead it gives an error message, " cannot open file, file is damaged". I have attached the function module that I call directly after calling the smartform. Can anybody help? I am using a ECC 6.0 System, Basis SP level 19 but had the same problem on v 4.7.

I tried to attach the code (I have tried with several sample programs provided on this forum), but it doesn't format correctly. Can someone give me a tip how to stop program code displaying in continuous text.

Sandra_Rossi
Active Contributor
0 Kudos

Prefer to use CL_BCS instead of function module, because this last is rather complex to use (when you don't know how it works you may easily get this kind of error).

The most frequent errors are the transmission of an incorrect binary length, or binary data was incorrectly converted (often because of Unicode systems).

You may generate manually the right PDF (smart form print preview, use PDF! in okcode field to display the PDF), and compare its binary content (bytes) with the PDF you currently generate (by comparing automatically or manually with any external softwares).

Former Member
0 Kudos

Hello Sandra

Thanks for your pointers. I have compared the PDF files and the one sent by mail is incomplete, about half the size it should be. I will look into this further to see where the data is being lost.

Best regards

Patricia

Former Member
0 Kudos

Dear Sandra

That was my problem: binary data was incorrectly converted (often because of Unicode systems).

I returned

bin_filesize = v_len_in

bin_file = l_binfile

from the function module CONVERT_OTF, then converted the xstring data (l_binfile) into an internal table (t_objbin) to send to the mail send function with the following function module:


    CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
      EXPORTING
        buffer        = l_binfile
      IMPORTING
        output_length = v_lines_bin
      TABLES
        binary_tab    = t_objbin.

Many thanks for your help.

Best regards

Patricia