STO mail : pdf attachment has an error 'file damage' when try to open it

Dear expert,
I need to send an e-mail to the vendor with the sto list as attachment at the email.
I managed to send email to external addresee and made the pdf attachment, BUT somehow when I open the attachment it has an error says "Adobe Reader could not open xx.pdf because it is either not a supported file type or because the file has been damaged(for axample, it was sent as an email attachment and wasn't corectly decoded)."
Really need your experties to help me. Here is my abap coding to send email and do the pdf attachment at the new ouptput type to send email.
  TYPES: BEGIN OF lty_drad,
          doknr TYPE drad-doknr,
         END OF lty_drad,
         BEGIN OF lty_recpt,
           smtp_addr  TYPE ad_smtpadr,
         END   OF lty_recpt.
  DATA: lt_doc      TYPE STANDARD TABLE OF docs,
        lt_recpt    TYPE STANDARD TABLE OF lty_recpt,
        lt_tline    LIKE tline OCCURS 0 WITH HEADER LINE,
        lt_data     TYPE solix_tab,
        lt_docu     TYPE STANDARD TABLE OF lty_drad,
        lt_docfiles TYPE STANDARD TABLE OF bapi_doc_files2,
        lw_tline    LIKE LINE OF lt_tline,
        lw_docu     LIKE LINE OF lt_docu,
        lw_docfiles LIKE LINE OF lt_docfiles,
        lw_objdes   TYPE tnati-objdes,
        lt_text     TYPE bcsy_text,
        lw_recpt    TYPE adr6-smtp_addr,
        lw_adrnr    TYPE lfa1-adrnr,
        lw_object   TYPE drad-objky,
        lw_doknr    TYPE drad-doknr,
        lw_return   TYPE  bapiret2,
        lw_xcontent TYPE xstring,
        client    TYPE REF TO if_http_client,
         url       TYPE string,
         lw_subrc  TYPE sysubrc,
         response  TYPE REF TO if_http_response,
         lw_message1 TYPE string,
       sent_to_all TYPE os_boolean,
       bin_filesize type i.
  CONSTANTS: lc_dokar_srm TYPE drad-dokar VALUE 'SRM',
             lc_type      TYPE so_obj_tp  VALUE 'RAW'.
CLASS-DEFINITIONS
  DATA: send_request       TYPE REF TO cl_bcs.
  DATA: document           TYPE REF TO cl_document_bcs.
  DATA: sender             TYPE REF TO cl_sapuser_bcs.
  DATA: recipient          TYPE REF TO if_recipient_bcs.
  DATA: exception_info     TYPE REF TO if_os_exception_info,
        bcs_exception      TYPE REF TO cx_bcs.
  RANGES: lr_po_pr   FOR  drad-objky.
  DATA:   lw_banfn   TYPE ekpo-banfn,
          lw_bnfpo   TYPE ekpo-bnfpo.
  IF nast-nacha = '5'. "8
Create recipient and check if exist
   Get email ID
  start commented by sapnislina 21.12.06
   SELECT SINGLE adrnr FROM lfa1 INTO lw_adrnr
                WHERE lifnr = p_ekko-lifnr.
   IF sy-subrc NE 0.
     PERFORM protocol_update
       USING '303' 'Address of Vendor:' ekko-lifnr 'not found' space
     p_retco = sy-subrc.
     EXIT.
   ENDIF.
  end commented by sapnislina 21.12.06
   SELECT smtp_addr INTO CORRESPONDING FIELDS OF TABLE lt_recpt
        FROM adr6
       WHERE addrnumber = p_ekko-adrnr. "lw_adrnr.
    IF lt_recpt[] IS INITIAL.
      PERFORM protocol_update
        USING '303' 'Email address(es) does not exist for vendor'
        p_ekko-lifnr space space.
      p_retco = sy-subrc.
      EXIT.
    ENDIF.
    CALL FUNCTION 'CONVERT_OTF_2_PDF'
      EXPORTING
        use_otf_mc_cmd         = 'X'
      IMPORTING
        bin_filesize           = bin_filesize
      TABLES
        otf                    = otfdata[]
        doctab_archive         = lt_doc
        lines                  = lt_tline
      EXCEPTIONS
        err_conv_not_possible  = 1
        err_otf_mc_noendmarker = 2
        OTHERS                 = 3.
    IF sy-subrc <> 0.
    PERFORM protocol_update
        USING '303' 'PO Convertion from OTF to PDF failed'
              space space space.
      p_retco = sy-subrc.
      EXIT.
    ENDIF.
Get object description from mail title of output types
   SELECT SINGLE objdes INTO lw_objdes
          FROM tnati
          WHERE spras = sy-langu
          AND   kappl = nast-kappl
          AND   kschl = nast-kschl.
   CONCATENATE lw_objdes ekko-ebeln INTO lw_objdes SEPARATED BY
space
    DATA L_TXT(255) TYPE C.
    DATA L_TXT2(255) TYPE C.
    CONCATENATE 'STO' EKPO-EBELN 'Created for' EKPO-WERKS '/'
EKPO-LGORT
    'Supply Plant' EKKO-RESWK into l_txt separated by space.
    lw_objdes = l_txt.
    CONCATENATE 'STO' EKKO-EBELN INTO L_TXT2 SEPARATED BY SPACE.
    APPEND L_TXT2 TO LT_TEXT.
   APPEND lw_objdes TO lt_text.
Instantiate
    CLASS cl_cam_address_bcs DEFINITION LOAD.
    CLASS cl_abap_char_utilities DEFINITION LOAD.
insert by sapnislina 22.12.06
  DATA : CONTENT_OUT TYPE SOLIX,
         LINE_WIDTH_SRC TYPE I,
         POS_OUT TYPE I,
         POS_IN TYPE I,
         LEN_OUT TYPE I.
  DATA OBJBIN LIKE SOLISTI1 OCCURS 0 WITH HEADER LINE.
  DATA : BEGIN OF CONTENT_IN,
            LINE TYPE TLINE,
            DUMMY TYPE TLINE,
         END OF CONTENT_IN.
  TYPES PDF_RAW TYPE X LENGTH 268.
  FIELD-SYMBOLS <PDF_BIN> TYPE PDF_RAW.
  DESCRIBE FIELD CONTENT_IN-LINE LENGTH LINE_WIDTH_SRC IN BYTE MODE.
  REFRESH lt_data.
  CLEAR CONTENT_OUT.
  POS_OUT = 0.
  LOOP AT OTFDATA INTO CONTENT_IN-LINE.
    ASSIGN CONTENT_IN TO <PDF_BIN> CASTING.
    MOVE <PDF_BIN> TO CONTENT_OUT-LINE+POS_OUT.
    ADD LINE_WIDTH_SRC TO POS_OUT.
    WHILE POS_OUT >= 255.
      APPEND CONTENT_OUT TO lt_data.
      CLEAR CONTENT_OUT.
      SUBTRACT 255 FROM POS_OUT.
      IF POS_OUT > 0.
        POS_IN = LINE_WIDTH_SRC - POS_OUT.
        MOVE <PDF_BIN>+POS_IN TO CONTENT_OUT-LINE.
      ENDIF.
    ENDWHILE.
  ENDLOOP.
  IF POS_OUT > 0.
  APPEND CONTENT_OUT TO lt_data.
  ENDIF.
end inserted by sapnislina 22.12.06
starting to create attachment to mail
    TRY.
       CLEAR send_request .
Create persistent send request
        send_request = cl_bcs=>create_persistent( ).
Build the document
        document = cl_document_bcs=>create_document(
                            i_type    = lc_type  "RAW
                            i_text    = lt_text  "def of output type
                            i_length  = '12'
                            i_subject = lw_objdes ).
Attached the document object
        CALL METHOD document->add_attachment
          EXPORTING
            i_attachment_type    = 'PDF'
            i_attachment_subject = lw_objdes "definition of output
type
            i_attachment_size    = '12'
            i_att_content_hex    = lt_data.
completed first part to attached PO (pdf format) as attachment
Now attach the PO related attachments to the mail..
.... need to read from table DRAD and get all the attachment per PO
     at run time
     REFRESH: lr_po_pr."lt_return.
        CLEAR:   lr_po_pr,lw_return.
        MOVE  'ICP'  TO  lr_po_pr.
     CLEAR: lw_object.
completed second part for PO related attachments
Now prepare to send mail
Add document to send request
     CALL METHOD send_request->set_document( document ).
Get sender object
     sender = cl_sapuser_bcs=>create( sy-uname ).
Add sender
     CALL METHOD send_request->set_sender
       EXPORTING
         i_sender = sender.
     LOOP AT lt_recpt INTO lw_recpt
                      WHERE NOT smtp_addr IS INITIAL.
      recipient = cl_cam_address_bcs=>create_internet_address(
lw_recpt ).
Add recipient with its respective attributes to send request
        CALL METHOD send_request->add_recipient
          EXPORTING
            i_recipient = recipient
            i_express   = 'X'.
        CLEAR recipient.
     ENDLOOP.
Send the document
    CALL METHOD send_request->send
      RECEIVING
        result              = sent_to_all.
Catch any exception
      CATCH cx_bcs INTO bcs_exception.
          CALL FUNCTION 'NAST_PROTOCOL_UPDATE'
            EXPORTING
              msg_arbgb = bcs_exception->msgid
              msg_nr    = bcs_exception->msgno
              msg_ty    = bcs_exception->msgty
              msg_v1    = bcs_exception->msgv1
              msg_v2    = bcs_exception->msgv2
              msg_v3    = bcs_exception->msgv3
              msg_v4    = bcs_exception->msgv4
            EXCEPTIONS
              OTHERS    = 1.
          p_retco = sy-subrc.
    ENDTRY.
  ENDIF.
  IF NOT result-tdfaxid  IS INITIAL OR                      " 422131
     NOT result-tdmailid IS INITIAL.                        " 422131
    CLEAR syst-msgv1.                                       " 422131
    IF NOT result-tdfaxid IS INITIAL.                       " 422131
      syst-msgv1 = result-tdfaxid.                          " 422131
    ELSEIF result-tdmailid IS INITIAL.                      " 422131
      syst-msgv1 = result-tdmailid.                         " 422131
    ENDIF.                                                  " 422131
    CALL FUNCTION 'NAST_PROTOCOL_UPDATE'                    " 422131
         EXPORTING                                          " 422131
              msg_arbgb = 'VN'                              " 422131
              msg_nr    = '095'                             " 422131
              msg_ty    = 'I'                               " 422131
              msg_v1    = syst-msgv1                        " 422131
         EXCEPTIONS                                         " 422131
              OTHERS    = 1.                                " 422131
  ENDIF.                                                    " 422131
  IF result-userexit EQ 'C' OR
      result-userexit EQ 'E'.
    p_retco = '9'.
  ENDIF.
ENDFORM.                               " ENDE
end inserted
Regards
Nislina

Hi Nislina,
Could you please let me know how do you solve this issue.
Code:
if lt_binary[] is not initial.
*     add attachment to document
         call method document->add_attachment
           exporting
             i_attachment_type      = 'PDF'            
             i_attachment_subject = 'My Attachment'
             i_att_content_hex      = lt_binary.
  endif.
Thanks & Regard's
Sateesh

Similar Messages

  • Error File missing when try to run iTunes on windows. No more info. Uninstalled following support instructions and reinstalled - same message while reinstalling.

    Error "File missing" when try to run iTunes on windows. No more info. Uninstalled following support instructions and reinstalled - same message while reinstalling.

    Hi there slklug43,
    You may find the troubleshooting steps in the article below helpful.
    iTunes for Windows Vista, Windows 7, or Windows 8: Fix unexpected quits or launch issues
    http://support.apple.com/kb/ts1717
    -Griff W. 

  • Bookmarks back-up on flashdrive says "unsupported file type" when try to open

    I followed the Help directions for backing up my bookmarks. But when I try to open the back-up file from a flashdrive, it says "unsupported file type." Also, when i save the back-up file to the desktop, it never gives me the option to choose that back-up file when I try to restore. Thanks!! :-)

    Make sure that the backup file with the bookmarks has the correct file extension: .html for a HTML backup and .json for a JSON backup.<br />
    You can check that via the right-click context menu of that file and open the Properties.<br />
    If you are not sure about the file type then you can open the file in Firefox via "File > Open File"<br />
    A JSON backup will show as one long text line without line breaks and a HTML backup as a web page with clickable links.
    A JSON backup starts with: <nowiki>{"title":"","id":1,"dateAdded":</nowiki>
    An HTML backup starts with: <nowiki><!DOCTYPE NETSCAPE-Bookmark-file-1></nowiki>

  • Is Creative Suite 6 and Captivate6 are windows8.1 compatible? Inform them of the errors you received when trying to install Captivate6 and the attachment has the errors I received when trying to install Creative suite 6.

    is creative suite 6 and captivate 6 are windows 8.1 compatible?  The attached shows errors when attempting to install.

    You will have to copy and paste the error messages into your posting.  Attachments are not supported for these forums.

  • I am having trouble with pdf files  continuously get damaged file message when try to open downloaded pdf with adobe reader

    Cannot open downloaded pdf's with adobe reader. Have latest version of adobe program  continuously get damaged file message.  Anybody else having this problem?   Using imac with osx10.7.1 (latest lion)

    I am having the exact same problem. This is very disturbing.
    Lately I have been deluged with adobe update dialogues. I don't know whether this is real or some kind of bugus malware phenomenon.
    Imagine my surprise when I looked here in the forum and I am not alone.
    Kaufmann's remark that we shouldn't be using adobe reader doesn't explain why it is malfunctioning like this. I have been using the reader on Mac  OS for years, and I don't get what's happening now.
    Does anyone realy know what is going on?

  • Press Quality PDFs created in CS4 show as "damaged" when attempting to open in Acrobat 5

    I've been having problems creating PDFs that can be opened in Acrobat 5. While using InDesign CS4, I'm trying to print to the Adobe PDF driver using the Press Quality setting, which as it states "can be opened with Acrobat and Adobe Reader 5.0 and later." However, when someone tries to open the resulting PDFs in Acrobat 5, they get a message saying "There was an error opening this document. The file is damaged and could not be repaired." They open just fine in Acrobat 9.
    I have been able to export to a PDF and get it to open successfully in Acrobat 5, but unfortunately this is not an option with one file I'm working on (I need to print color separations as a PDF and then pull it into PitStop Pro to make adjustments). Does anybody have any ideas as to why Acrobat 5 isn't able to read these PDFs?
    Running Windows Vista Business with SP1 on a Lenovo with an Intel Core2 Duo processor and 3GB of RAM.
    Thanks.

    If you print to the Adobe PDF printer you are creating a PS file that is then automatically loaded into Distiller for conversion to PDF. Printing to a different PS file should not make a difference, unless the PS driver is substantially different. You can also print to file with the Aodbe PDF printer and then convert with Distiller (eliminating the automatic Distiller step). If you are printing to a network location, that may be the issue. Acrobat has long had problems with some network connections. To check this out, you might print locally and then move the file to the network drive.
    In terms of posting a file, you have to put it on a separate server and then post the link.

  • Quicktime Error during Install/when try to open Itunes says encounterederro

    error....
    any ideas,fixes?
    Thanks

    I have the same probelm and I think it's also from upgrading to the free 7.1 version of iTunes.

  • I got a new Macbook pro in March and transferred all of my old files into the new macbook from my old one. But ever since then, my iPhoto just does not open up. It says 'error' every time I try to open it, but I am still able to attach the iPhotos saved

    I got a new Macbook pro in March and transferred all of my old files into the new macbook from my old one. But ever since then, my iPhoto just does not open up. It says 'error' every time I try to open it, but I am still able to attach the iPhotos saved to emails. Help! How do I get my iPhoto back?

    Thanks, Sig.
    The old computer is a 2.6 Ghz Intel Core 2 Duo
    The new one is a 2.3 GHz intel core i7
    In going over this, thanks to "tallking it out" with you, I did discover the Text Edit problem.  Because I've still been unable to get the new computer text size (fonts or whatever) to match the old computer, I did not notice that the curser is now different--the line midway down the curser has to be placed on the line I am working upon, otherwise the edits go elsewhere on the page.  Now, with a bit of difficulty, I am able to get Text Edit to work correctly.
    If you have any ideas as to why my menu bar and Text Edit type are still so slow, I'd love to have them. 
    (I went through the process you suggested earlier, re my Trackpad preferences, and found no improvement.)

  • Error code = 0x40010015 when trying to open PDF in PS CS3

    Greetings:
    I'm having a problem opening a PDF file in Photoshop.
    This is the error message:
    Error Opening the Portable Document File
    (PDF) Document. Error Code =
    0x40010015
    Searching the Adobe Forums, Knowledge Base, and even Google has turned up no results. Any idea what the problem may be?
    My process has been taking a PDF file created from QuarkXpress (6.5) and opening it in Acrobat Pro (8.1.2) and doing a save as and replacing the current pdf. Then I open this new PDF file in Photoshop CS3 (10.0.1) and apply actions. No problems. Then I encountered this one file that won't open in Photoshop, but will open in Acrobat, Preview, Illustrator. I get the following error message.
    I'm using a G5 PowerPC Mac (4 x 2.5 GHz Processor) with 6.5 GB DDR2 SDRAM for memory. Mac OS X version 10.4.11 (haven't switched to Leopard yet) Adobe Creative Suite 3 Design Premium software package.
    Thanks,
    Randy Hinderks
    Art Director / Video Editor
    On-Purpos, Inc.

    I receive an error code = 0x40010015 when trying to open a PDF in Photoshop CS3 for windows.
    I do not have Illustrator to open and re-save as the forum discussion indicated.
    Is there another way to open a PDF with this error code?  I work with Quark, Photoshop and Publisher
    MartyMag22

  • "Internal error: An unexpected exception has occurred" error message displayed when browsing a cube.

    “Internal error: An unexpected exception has occurred“ error message displayed when browsing a cube.
    The error behaviour is quite irregular and does not occur for specific condition.
    Will cumulative update 9 for SQL Server 2008 R2 (SP1) installation help to fix the issue which is provided on the below link:
    (http://support.microsoft.com/kb/2152148)
    The current version of SQL Server I am using is as below:
    Microsoft SQL Server 2008 R2 (SP1) - 10.50.2500.0 (X64)   Jun 17 2011 00:54:03   Copyright (c) Microsoft Corporation  Enterprise Edition (64-bit) on Windows NT 6.1 <X64> (Build 7601: Service Pack 1)
    Thanks in advance for the help!

    Hi Mon,
    The hotfix you said is for Microsoft SQL Server 2008. So it will not work on your scenario since you are using SQL Server 2008 R2.
    Based on the limited information, we cannot give you the exact reason that cause this issue. In order to narrow down this issue, you can apply the latest Service Pack and Cumulative Update as GregGalloway said. Besides, you can troubleshoot this issue by
    using the Windows Event logs and msmdsrv.log.
    You can access Windows Event logs via "Administrative Tools" --> "Event Viewer".  SSAS error messages will appear in the application log.
    The msmdsrv.log file for the SSAS instance that can be found in \log folder of the instance. (C:\Program Files\Microsoft SQL Server\MSAS10.MSSQLSERVER\OLAP\Log)
    Here is a blog about data collection for troubleshooting Analysis Services issues, please see:
    Data collection for troubleshooting Analysis Services issues
    Regards,
    Charlie Liao
    TechNet Community Support

  • Error (file skipped) when combining files

    Getting an error message on some files(error file skipped)@ when combining files, the properties of the files with errors are the same as the files which are okay. Anyone got a fix for this?

    No the the files aren’t protected. But I solved the problem by copying the files to another folder.
    Seems like another process was still using the files(strange but that’s data for you)
    Fra: Bernd Alheit
    Sendt: 6. august 2014 18:52
    Til: Douglas McGaw
    Emne:  Error (file skipped) when combining files
    Error (file skipped) when combining files
    created by Bernd Alheit<https://forums.adobe.com/people/Bernd+Alheit> in Creating, Editing & Exporting PDFs - View the full discussion<https://forums.adobe.com/message/6617254#6617254>

  • Error: File "x.avi" cannot be opened (86::1)

    I've started using a new camera to record some footage and it saves videos in an .avi format with the H.264 codec.
    Everytime I try to import footage from the camera I get an error message saying 'After Effects error: File "X.avi" cannot be opened, it may be in an unsupported format ( 86::1 ).
    I use After Effects CC and this problem has never occured before. I have tried videos with both 1920x1080 and 1280x720 resolutions and the error still comes up. Converting the footage to another format works but slightly lowers the frame rate and sometimes messes up audio.
    Please Help

    Todd_Kopriva wrote:
    Can you play these .avi movies with this H.264 variant using media players on your computer, such as QuickTime Player or Windows Media Player?
    I can play them on all media players except from Quicktime which doesn't usually support AVI playback.

  • I have installed the latest version of iTunes for Windows 8 but when I try to open it, it says Windows has an error and I simply can't open it any longer.  Any help is appreciated!

    I have installed the latest version of iTunes for Windows 8 but when I try to open it, it says Windows has an error and I simply can't open it any longer.  Any help is appreciated!

    Hey socestlavie,
    Thanks for the question. I understand you are experiencing issues with iTunes for Windows. The following resource may help to resolve your issue:
    iTunes for Windows Vista, Windows 7, or Windows 8: Fix unexpected quits or launch issues
    http://support.apple.com/kb/TS1717
    Thanks,
    Matt M.

  • I tried opening my Mac files to windows by using Macdriver 8, however upon opening the file my previous mac folders were converted to windows shortcuts and upon returning to my mac pc, all my folders has a .lnk file extension which I cannot open.

    I tried opening my Mac files to windows by using Macdriver 8, however upon opening the file my previous mac folders were converted to windows shortcuts and upon returning to my mac pc, all my folders has a .lnk file extension which I cannot open. Need help very badly since the hard drive I use is the only back up I have for my very old pics. Thank you...

    Backup with cloning software your HD to have an exact copy of it as it is.
    Use this methodology to recover your partition.
    Have fun,
    Leo

  • TS3276 I just downloaded the OS X Lion mountain and Mail won't open.  I get an error message everytime I try to open the app.How can I fix that?

    I just downloaded the OS X Lion mountain and Mail won't open.  I get an error message everytime I try to open the app.How can I fix that?

    I-Photo won't open even though I have upgraded to OS X Yosemite and downloaded the I-Photo upgrader.
    But have you run the the iPhoto Library upgrader? It is installed in Applications > Utilities. Launch it and direct it to your iPhoto library.
    Which version of iPhoto did you upgrade from?
    The upgrader is only necessary, if you have been  running iPhoto7.1.2 or earlier.

Maybe you are looking for