Issue while opening Excel attachment send through FM

Hi All,
I had program in which i am sending mail along with Excel attachment using FM SO_NEW_DOCUMENT_ATT_SEND_API1. Mail is going fine with data in Excel attachment. But when i try to open the Excel it gives an Info message saying that "<b>You are trying to open (attachment name),is in different format than specified file extension Verify that file is not corrupted and is from a trusted source before opening file. Do you want to open file now</b>". Then when i presses YES, Excel opens up with all data. I want to know how to avoid that info popup. Is there something has to be passed to FM or something has to be done to Excel like settings in EXCEL so that i can avoid that Info message coming.
Document type of attachment is gw_packing_list-doc_type = 'XLS'.
Thanks in advance,
Shyam

Hi Shyam,
                Have you build your Excel Data table to get attachement in Mail? If no then please find the Eg. code for your reference to send Excel attachment..
* End of Selection Event : Displaying the selected data                *
END-OF-SELECTION.
    PERFORM EMAIL_EXCEL_ATTACHMENT.
******///form
FORM EMAIL_EXCEL_ATTACHMENT .
* Populate table with detaisl to be entered into .xls file
  PERFORM BUILD_XLS_DATA_TABLE.
* Populate message body text
  PERFORM POPULATE_EMAIL_MESSAGE_BODY.
* Send file by email as .xls speadsheet
  PERFORM SEND_FILE_AS_EMAIL_ATTACHMENT
                               TABLES IT_MESSAGE
                                      IT_ATTACH
                                USING S_EMAIL
                                      TEXT-042
                                      C_XLS
                                      'filename'
                             CHANGING GD_ERROR
                                      GD_RECIEVER.
*   Instructs mail send program for SAPCONNECT to send email(rsconn01)
  PERFORM INITIATE_MAIL_EXECUTE_PROGRAM.
ENDFORM.                    " EMAIL_EXCEL_ATTACHMENT
********///form BUILD_XLS_DATA_TABLE
FORM BUILD_XLS_DATA_TABLE .
  DATA :    LV_NETWR(20)     TYPE C,
            LV_BOL_DATE(20)  TYPE C,
            LV_KAWRT(20)     TYPE C,
            LV_FKDAT(20)     TYPE C,
            LV_WAERK(20)     TYPE C,
            LV_KURRF(20)     TYPE C,
            LV_SHIPDATE(20)  TYPE C,
            LV_DEPTDATE(20)  TYPE C.
  CONSTANTS:
      CON_TAB  TYPE C VALUE CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB,
      CON_CRET TYPE C VALUE CL_ABAP_CHAR_UTILITIES=>CR_LF.  "#EC *
  DATA STR TYPE STRING.
**********/ this parameter concatenate to get headers
  CONCATENATE STR
  'SLNO'
  'OWNER'
  'SERIAL NO'
  'FROM'
  'DESTINATION'
  'INVOICE VALUE'
  'DESCRIPTION'
  'CUSTOMER NAME'
  'BL NUMBER'
  'BL DATE'
  'VESSEL NAME/AIRLINE DETAILS'
  'MODE OF TRANSIT'
  'SHIPPING MARKS'
  'DUTY SUM INSURED'
  'FLAG'
  'OPEN COVERNO'
  'INVOICE DATE'
  'INVOICE NO'
  'LC WORDING'
  'QUANTITY'
  'PACKAGING DETAILS'
  'BASIS OF VALUATION'
  'EXCLUDE WAR SRCC'
  'CURRENCY'
  'EXCHANGE RATE'
  'ADDRESS'
  'VESSEL BUILT YEAR'
  'VESSEL FLAG'
  'VOYAGE NO'
  'SHIPMENT DATE'
  'DEPARTURE DATE'
  'SURVEYOR COUNTRY'
  'SURVEYOR CITY'
  'SURVEYOR AGENT'
  'SURVEYOR ADDRESS'
  'EXPORT CONSIGNMENT'
  'CONTAINER DETAILS'
  CL_ABAP_CHAR_UTILITIES=>CR_LF INTO STR SEPARATED BY CON_TAB.
  LOOP AT IT_FINAL.
*******/ this is to pass body / row data
    WRITE : IT_FINAL-NETWR    TO LV_NETWR,              "#EC UOM_IN_MES
            IT_FINAL-BOL_DATE TO LV_BOL_DATE,
            IT_FINAL-KAWRT    TO LV_KAWRT,              "#EC UOM_IN_MES
            IT_FINAL-FKDAT    TO LV_FKDAT,
            IT_FINAL-WAERK    TO LV_WAERK,
            IT_FINAL-KURRF    TO LV_KURRF,
            IT_FINAL-SHIPDATE TO LV_SHIPDATE,
            IT_FINAL-DEPTDATE TO LV_DEPTDATE.
    CONCATENATE
           STR
           IT_FINAL-SLNO
           IT_FINAL-OWNER
           IT_FINAL-SRNO
           IT_FINAL-PORT_LOAD
           IT_FINAL-PORT_DSCHR
           LV_NETWR
           IT_FINAL-DESCRIP
           IT_FINAL-CUSTNAME
           IT_FINAL-BOL_NUM
           LV_BOL_DATE
           IT_FINAL-VESSELNAME
           IT_FINAL-SHP_TYPE
           IT_FINAL-SHP_MARK
           LV_KAWRT
           IT_FINAL-FLAG
           IT_FINAL-OPEN_CONO
           LV_FKDAT
           IT_FINAL-VBELN
           IT_FINAL-LC_WORD
           IT_FINAL-QUANT
           IT_FINAL-PACKDETL
           IT_FINAL-INCO1
           IT_FINAL-EXCWSR
           LV_WAERK
           LV_KURRF
           IT_FINAL-ADDPAY
           IT_FINAL-VESSBYR
           IT_FINAL-VESSFLG
           IT_FINAL-VOY_FLY_NO
           LV_SHIPDATE
           LV_DEPTDATE
           IT_FINAL-SURCOUNT
           IT_FINAL-INCO2
           IT_FINAL-EXPORT_CON
           IT_FINAL-SURAGT
           IT_FINAL-SURADD
           IT_FINAL-CONTRNO
   CL_ABAP_CHAR_UTILITIES=>CR_LF INTO STR SEPARATED BY CON_TAB.
  ENDLOOP.
  CALL FUNCTION 'SCMS_STRING_TO_FTEXT'
    EXPORTING
      TEXT      = STR
    TABLES
      FTEXT_TAB = IT_ATTACH.
ENDFORM.                    " BUILD_XLS_DATA_TABLE
******// form POPULATE_EMAIL_MESSAGE_BODY
FORM POPULATE_EMAIL_MESSAGE_BODY .
  REFRESH IT_MESSAGE.
  IT_MESSAGE = TEXT-043.  " Please find attached Insurance Certificate details
  APPEND IT_MESSAGE.
ENDFORM.                    " POPULATE_EMAIL_MESSAGE_BODY
*******'/ form SEND_FILE_AS_EMAIL_ATTACHMENT
*&      Form  SEND_FILE_AS_EMAIL_ATTACHMENT
*       text
*      -->PIT_MESSAGE           text
*      -->PIT_ATTACH            text
*      -->P_EMAIL               text
*      -->P_MTITLE              text
*      -->P_FORMAT              text
*      -->P_FILENAME            text
*      -->P_ATTDESCRIPTION      text
*      -->P_SENDER_ADDRESS      text
*      -->P_SENDER_ADDRES_TYPE  text
*      -->P_ERROR               text
*      -->P_RECIEVER            text
FORM SEND_FILE_AS_EMAIL_ATTACHMENT TABLES PIT_MESSAGE
                                          PIT_ATTACH
                                    USING P_EMAIL
                                          P_MTITLE
                                          P_FORMAT
                                          P_FILENAME
                                          P_ATTDESCRIPTION
                                          P_SENDER_ADDRESS
                                          P_SENDER_ADDRES_TYPE
                                 CHANGING P_ERROR
                                          P_RECIEVER.       "#EC *
  DATA: LD_ERROR    TYPE SY-SUBRC,                          "#EC *
*        LD_RECIEVER TYPE SY-SUBRC,
        LD_MTITLE LIKE SODOCCHGI1-OBJ_DESCR,
*        LD_EMAIL LIKE  SOMLRECI1-RECEIVER,
        LD_FORMAT TYPE  SO_OBJ_TP ,
        LD_ATTDESCRIPTION TYPE  SO_OBJ_NAM ,
        LD_ATTFILENAME TYPE  SO_OBJ_DES ,
        LD_SENDER_ADDRESS LIKE  SOEXTRECI1-RECEIVER,
        LD_SENDER_ADDRESS_TYPE LIKE  SOEXTRECI1-ADR_TYP,
        LD_RECEIVER LIKE  SY-SUBRC.                         "#EC *
*  ld_email   = p_email.
  LD_MTITLE = P_MTITLE.
  LD_FORMAT              = P_FORMAT.
  LD_ATTDESCRIPTION      = P_ATTDESCRIPTION.
  LD_ATTFILENAME         = P_FILENAME.
  LD_SENDER_ADDRESS      = P_SENDER_ADDRESS.
  LD_SENDER_ADDRESS_TYPE = P_SENDER_ADDRES_TYPE.
* Fill the document data.
  W_DOC_DATA-DOC_SIZE = 1.
* Populate the subject/generic message attributes
  W_DOC_DATA-OBJ_LANGU = SY-LANGU.
  W_DOC_DATA-OBJ_NAME  = 'SAPRPT'.
  W_DOC_DATA-OBJ_DESCR = LD_MTITLE .
  W_DOC_DATA-SENSITIVTY = 'F'.
* Fill the document data and get size of attachment
  CLEAR W_DOC_DATA.
  DESCRIBE TABLE IT_ATTACH LINES W_CNT.
  READ TABLE IT_ATTACH INDEX W_CNT.
  W_DOC_DATA-DOC_SIZE =
     W_CNT * 255 + STRLEN( IT_ATTACH ).
  W_DOC_DATA-OBJ_LANGU  = SY-LANGU.
  W_DOC_DATA-OBJ_NAME   = 'SAPRPT'.
  W_DOC_DATA-OBJ_DESCR  = LD_MTITLE.
  W_DOC_DATA-SENSITIVTY = 'F'.
  CLEAR T_ATTACHMENT.
  REFRESH T_ATTACHMENT.
  T_ATTACHMENT[] = PIT_ATTACH[].
* Describe the body of the message
  CLEAR T_PACKING_LIST.
  REFRESH T_PACKING_LIST.
  T_PACKING_LIST-TRANSF_BIN = SPACE.
  T_PACKING_LIST-HEAD_START = 1.
  T_PACKING_LIST-HEAD_NUM = 0.
  T_PACKING_LIST-BODY_START = 1.
  DESCRIBE TABLE IT_MESSAGE LINES T_PACKING_LIST-BODY_NUM.
  T_PACKING_LIST-DOC_TYPE = 'raw'.
  APPEND T_PACKING_LIST.
* Create attachment notification
  T_PACKING_LIST-TRANSF_BIN = 'X'.
  T_PACKING_LIST-HEAD_START = 1.
  T_PACKING_LIST-HEAD_NUM   = 1.
  T_PACKING_LIST-BODY_START = 1.
  DESCRIBE TABLE T_ATTACHMENT LINES T_PACKING_LIST-BODY_NUM.
  T_PACKING_LIST-DOC_TYPE   =  LD_FORMAT.
  T_PACKING_LIST-OBJ_DESCR  =  LD_ATTDESCRIPTION.
  T_PACKING_LIST-OBJ_NAME   =  LD_ATTFILENAME.
  T_PACKING_LIST-DOC_SIZE   =  T_PACKING_LIST-BODY_NUM * 255.
  APPEND T_PACKING_LIST.
* Add the recipients email address
  CLEAR T_RECEIVERS.
  REFRESH T_RECEIVERS.
  LOOP AT S_EMAIL.
    T_RECEIVERS-RECEIVER = S_EMAIL-LOW.
    T_RECEIVERS-REC_TYPE = 'U'.
    T_RECEIVERS-COM_TYPE = 'INT'.
    T_RECEIVERS-NOTIF_DEL = 'X'.
    T_RECEIVERS-NOTIF_NDEL = 'X'.
    APPEND T_RECEIVERS.
  ENDLOOP.
  CALL FUNCTION 'SO_DOCUMENT_SEND_API1'
    EXPORTING
      DOCUMENT_DATA              = W_DOC_DATA
      PUT_IN_OUTBOX              = 'X'
      SENDER_ADDRESS             = LD_SENDER_ADDRESS
      SENDER_ADDRESS_TYPE        = LD_SENDER_ADDRESS_TYPE
      COMMIT_WORK                = 'X'
    IMPORTING
      SENT_TO_ALL                = W_SENT_ALL
    TABLES
      PACKING_LIST               = T_PACKING_LIST
      CONTENTS_BIN               = T_ATTACHMENT
      CONTENTS_TXT               = IT_MESSAGE
      RECEIVERS                  = T_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.
* Populate zerror return code
  LD_ERROR = SY-SUBRC.
* Populate zreceiver return code
  LOOP AT T_RECEIVERS.
    LD_RECEIVER = T_RECEIVERS-RETRN_CODE.
  ENDLOOP.
ENDFORM.                    " SEND_FILE_AS_EMAIL_ATTACHMENT
*******/form
*&      Form  INITIATE_MAIL_EXECUTE_PROGRAM
*       text
*  -->  p1        text
*  <--  p2        text
FORM INITIATE_MAIL_EXECUTE_PROGRAM .
  WAIT UP TO 2 SECONDS.
  SUBMIT RSCONN01 WITH MODE = 'INT'
                WITH OUTPUT = 'X'
                AND RETURN.
ENDFORM.                    " INITIATE_MAIL_EXECUTE_PROGRAM
*********end of code to trigger mail in excel format....
If any other help please let me know......
I am sure this example code will help you to resolve your problem...
please analyse above code for your requirement...
In my scenario the message you said is not displaying.....
<i>Reward Points</i>
Cheers,
Sagun Desai

Similar Messages

  • Cache issue while opening an attachment

    Hi,
    We are facing the cache problem while opening an attachment in the webdynpro application.
    When we clear the cache of the browser, then we are able to open the attachment.
    Can we prevent this from the application side.
    All the attachments are stored in the backend (CRM) system.
    Regards
    MQ

    Hi,
    We are facing the cache problem while opening an attachment in the webdynpro application.
    When we clear the cache of the browser, then we are able to open the attachment.
    Can we prevent this from the application side.
    All the attachments are stored in the backend (CRM) system.
    Regards
    MQ

  • Error while opening Excel file sent through attachment in email in sap

    Hi All,
    I have implemented sending email with excel attachment in SAP.
    Email is sent successfully with attachment but when i tried to open it i get first error dialog like " file is not in recognizable format" but after that if i click ok then file gets opened correctly.
    Can you please sort this out.
    Thanks in advance.
    regards
    Ashutosh

    Go to the following link you will get solutions:
    ABAP BASIC

  • Vendors are not able to open Payment advices send through SAP

    Hi,
    We regularly send payment advices to our Vendors thorugh Payment programme F110. but all of sudden many of vendors are facing issue while opening PDF File.
    Some of them are getting Error as "Adobe reader could not open file because it is either not supported file or because file has been damaged(it was sent as an email attachment and wasn't correctly decoded) while some of them are receiving Blank attachment.
    Also when we try to send same file to internal id's and our personal Id's we are able to open same. So this is not sap problem as file leaves sap correctly.
    Also one more observation is when correct file is received by us the file size is of 8KB while same when received by Vendors its only of 1 KB i.e it consist of only disclaimer and no PDF File
    Please let me know solution for this at earliest as many vendors are facing this issue.
    Regards
    Tanuja Naik

    HI,
    We had also checked settings at our Mail server and our security software trend Micro and mails are seen to be properly send through same.
    Actually we Shifted from Exchnage Server 2003 to 2007 in month of February. After that these Problems started Cropping up.
    and Now that its almost a month, this has become serious issue.
    Please let me know if anybody knows solution for this. This doesn;t look to be problem of SAP.
    Thanks in Advance
    tanuja Naik
    022-67782645

  • Error while opening PDF attachment sent via mail

    Hi,
    I am attaching PDF file to PO in me22n and sending the same file as attachment in the mail to the vendor using class CL_BCS.
    The mail is sent to the vendor successfully and they are able to successfully open the PDF attachment. But in some cases the mail is successfully received but while opening the attachment it is giving the error as file is corrupted.
    Please help me to resolve this issue.
    Thanks and regards,
    Jayashree

    Hi,
    I would like to know what font type, you are using in the forms.
    Ideally it should be HELVETICA .
    If you are using any other font in your style/form,try changing it to HELVETICA & Test.
    Also Check the OTF data at the call of gen. FM,before converting it to PDF.
    Regds,
    AS
    Edited by: abheesawant on Oct 12, 2011 7:48 AM

  • Getting error while opening Excel document from SharePoint site

    Hello All,
    I am getting following error while opening Excel document from SharePoint site.
    This issue appears when we open Excel document from Windows>> Run using below mentioned command:
    Excel.exe "{File Name}"
    If once I go to Excel back stage and browse for the SharePoint location, then this problem disappears.
    I have a work around for this issue but main problem is that i do not have any work around when i need to open Exel document using Excel COM interop in C#.
    Thanks,
    Amit Bansal
    Amit Bansal http://www.oops4you.blogspot.com/

    Hi Amit Bansal,
    Thanks for posting in MSDN forum.
    This forum is for developers discussing developing issues involve Excel application.
    According to the description, you got an error when you open the document form SharePoint site.
    Based on my understanding, this issue maybe relative to the SharePoint, I would like move it to
    SharePoint 2013 - General Discussions and Questions forum.
    The reason why we recommend posting appropriately is you will get the most qualified pool of respondents, and other partners who read the forums regularly can either share their knowledge or learn from your interaction with us.
    Thanks for your understanding.
    Regards & Fei
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • Starting AMT FailedI am facing the same issue while opening AMT/Mobile Sale

    Hi All,
    I am facing a issue while opening AMT/Mobile Sales Appl/System Maintenance. I am getting the error saying 'UI_CORE_APPL_LAUNCH_FAILED_STA'. Could anyone out there  please tell me how to resolve this issue?
    I checked the UID and PWD under HKEY_LOCAL_MACHINE\SOFWARE\SAP\MSA\MW\secutiry for IDES DB and they are consistent with the ODBC parameters for IDES.
    Much appreciated,
    Karuna.

    Hi All,
    my issue is resolved. The problem with my issue was the missing entry in the table SMO_AUTH_SYS. I found the note 687679 and ran the report according to it. With that table SMO_AUTH_SYS was populated with the record. Later i was able to connect to AMT and gave the standard role SAP_AMT_USER and since then i am able to log into MSAA application and also MSY application
    My issue is resolved. Thanks for everyone who tried to help me out.
    Thanks,
    Karuna.

  • Issue while opening BI4 webi report instance using CMC on IE8 browser

    Hi,
    Having issue while opening BI4 webi report instance using CMC on IE8 browser.
    Steps to reproduce the error:
    1. Login to CMC
    2.  View Webi History.
    3.  Open successful instance  (For the 1st or 2nd time reports are opening up, from the 3rd time it just freeze the session)
    4. After it get freeze we need to close the IE using Task Manager.
    Can any one please suggest a resolution for this issue.
    Thanks,
    Ganesh.M

    Hello Gokul,
    first thing is to check is if your chrome version is supported by your current BO version as specified in the PAM (is it?). If the chrome version is supported, and you still have an issue, then you can check with a sap support engineer.
    best regards,
    Victor

  • Issue while opening webi reports using OpenDoc url in Chrome browser

    Hi
    We are in SAP BI4.0 SP7. We are facing weird issue while opening the webi report via OpenDoc url in chrome. we are facing the below issue only in chrome and it works perfectly in IE and Firefox.
    For the first time the report gets opened properly(when a session is created). If we try to open the same report from the same machine in a different browser tab, report gets opened up without any Tables\charts. We could see only a blank page with just the Report Tab name at the bottom. If we do refresh on the page, the report opens up correctly. We have checked for packet drops and there is no such thing. Is there any setting that we should make to resolve this. Your help is appreciated.
    thanks
    Gokul

    Hello Gokul,
    first thing is to check is if your chrome version is supported by your current BO version as specified in the PAM (is it?). If the chrome version is supported, and you still have an issue, then you can check with a sap support engineer.
    best regards,
    Victor

  • Performance issue while opening the report

    HI,
    I am working BO XI R3.1.there is performance issue while opening the report in BO Solris Server but  on window server it is compratively fast.
    we have few reports which contains 5 fixed prompt 7 optional prompt.
    out of 5 fixed prompt 3 prompt is static (it contains 3 -4 record only )which is coming from materlied view.
    we have already use many thing for improve performance in report like-
    1) Index Awareness
    2) Aggregate Awareness
    3) Array fatch size-250
    3) Aray bind time -32767
    4) Login time out -600
    the issue is that before refresh opening the report iteslf taking time 1.30 min on BO solris server but same report taking time in BO window server 45 sec. even we  import on others BO solris server it is taking same time as per old solris server(1.30 min).
    when we close the trace in solris server than it is taking 1.15  sec time.it should not be intial phase it is not hitting more on database.so why it is taking that much time while opening the report.
    could you please guide us where exectly problem is there and how we can improve performance for opening the report.In case the problem related to solris server so what would be and how can we rectify.
    Incase any further input require for the same feel free to ask me.

    Hi Kumar,
    If this is happening with all the reports then this issue seems to be due to firewall or security settings of Solaris OS.
    Please try to lower down the security level in solaris and test for the issue.
    Regards,
    Chaitanya Deshpande

  • Error while trying to open an attachment  sent through email in smartform

    Hi,
    My requirement is to send the smartform through email as PDF attachment.I am able to send the mail.But when I try to open the attachment I am getting error as 'Adobe reader could not open the attachment 'advance shipment notification.PDF' because it is either not the supported file type or the file has been corrupted(for example, it was sent as an email attachment and was't correctly decoded)'.What does it mean?
    Can anyone give me a proper solution for this?
    It's very urgent.Useful answers will be rewarded.
    Thanks,
    Hema

    Hi,
    Are you using any webdispatcher or some proxy? Is there any URL filter configured in between?
    If yes then I think you have to allow these pages.
    Regards,
    Vamshi.

  • Problem while opening Excel through OLE

    Hi Friends
    I am facing a problem while opening an excel file through OLE. it is working fine in SAP ECC 5.0, but the problem is in ECC 6.0.
    I am adjusting the cells for auto fit. I have written the code like below.
    CALL METHOD OF e_appl 'CELLS' = e_cell.
      CALL METHOD OF e_cell 'EntireColumn' = ole_columns .
      CALL METHOD OF ole_columns 'AutoFit'.
      set property of e_appl 'VISIBLE' = 1.
    if I take out the adjustment part it is working fine for this program, rest other programs even if I have this code, they working fine.
    When I am executing the statement set property of e_appl 'VISIBLE' = 1. the return code is coming as 2.
    Could anybody please help me to overcome this problem.
    Thanks
    Praveen

    In ECC 6.0, if the worksheet is portedcted SAP unable to open that sheet, now we have taken out this option so it is working.

  • Issues while opening a UTF16 encoded .csv file in excel using c#

    When I tried to open a UTF8 encoded
    .csv file in excel through my c# code, doing something like this:
    m_excel.Workbooks.OpenText(newPath, Comma: true);
    That works fine. Can anyone tell me what to do if I had to open a UTF16 encoded
    .CSV file similarly. All options i tried either fails or print incorrect Unicode characters.
    So somehow we have to specify the encoding format (of the file to be opened i.e .CSV)  while opening using excel functions, which i am unable to figure out.
    Please help me. I am badly stuck here.
    Thanks in advance.

    Hi Jb9952,
    There is an Origin parameter in
    Workbooks.OpenText method, you need to specify this parameter. You could try to use xlWindows (Windows ANSI).
    To get the specify file origin value, you could get the detail code through Record Macro feature in excel.
    Regards
    Starain
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • Error while Opening PDF attachment from Mail

    Hi,
    We two Output Types created ZNEU and ZAUF. Two Smartforms are created for the same Output Types. The Issue now is, When ZNEU triggers and send a mail the document is properly decoded and gets opened but for ZAUF it doesn't. It says File damaged.
    This is the code we have used for sending mail.
    CONSTANTS:
              co_pdf(3) TYPE c VALUE 'PDF',
              co_raw(3) TYPE c VALUE 'RAW'.
      DATA:
            it_objbin TYPE STANDARD TABLE OF solisti1,
            wa_objbin TYPE solisti1.
      DATA:
             lv_filesize TYPE i.
      DATA:
            it_lines TYPE STANDARD TABLE OF tline.
      DATA:
            wa_mail_body TYPE solisti1,
            wa_receipients TYPE somlreci1.
      DATA:
           document           TYPE REF TO cl_document_bcs,
           content            TYPE solix_tab,
           wa_content         TYPE solix,
           send_request       TYPE REF TO cl_bcs,
           sender             TYPE REF TO if_sender_bcs,
           recipient          TYPE REF TO if_recipient_bcs,
           requested_status   TYPE REF TO bcs_rqst,
           status_mail        TYPE bcs_stml,
           bcs_exception      TYPE REF TO cx_bcs,
           lv_rec             TYPE adr6-smtp_addr.
      DATA:
             wa_attachx TYPE solix,
             l_pdf_len TYPE i,
             l_con_len TYPE i,
             l_pdf_pos TYPE i,
             l_con_pos TYPE i.
      FIELD-SYMBOLS: <fs_con> TYPE x.
      CLASS cl_cam_address_bcs     DEFINITION LOAD.
      CLASS cl_abap_char_utilities DEFINITION LOAD.
    * Get the PDF version of the OTF
      CALL FUNCTION 'CONVERT_OTF'
       EXPORTING
         format                      = 'PDF'
       IMPORTING
         bin_filesize                = lv_filesize
        TABLES
          otf                         = job_output_info-otfdata
          lines                       = it_lines
       EXCEPTIONS
         err_max_linewidth           = 1
         err_format                  = 2
         err_conv_not_possible       = 3
         err_bad_otf                 = 4
         OTHERS                      = 5.
      IF sy-subrc <> 0.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    * Convert the PDF format to the table type required for the attachment.
      CALL FUNCTION 'QCE1_CONVERT'
        TABLES
          t_source_tab         = it_lines
          t_target_tab         = it_objbin
        EXCEPTIONS
          convert_not_possible = 1
          OTHERS               = 2.
      IF sy-subrc <> 0.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    * Convert the data which is in text to binary
      l_con_pos = 0.
      DESCRIBE FIELD wa_objbin LENGTH l_pdf_len IN BYTE MODE.
      DESCRIBE FIELD wa_attachx LENGTH l_con_len IN BYTE MODE.
      LOOP AT it_objbin INTO wa_objbin.
        ASSIGN wa_objbin TO <fs_con> CASTING.
        CHECK sy-subrc EQ 0.
        DO l_pdf_len TIMES.
          l_pdf_pos = sy-index - 1.
          IF l_con_pos = l_con_len.
            APPEND wa_attachx TO content.
            FREE wa_attachx.
            l_con_pos = 0.
          ENDIF.
          MOVE <fs_con>+l_pdf_pos(1) TO wa_attachx-line+l_con_pos(1).
          ADD 1 TO l_con_pos.
        ENDDO.
      ENDLOOP.
      IF l_con_pos > 0.
        APPEND wa_attachx TO content.
      ENDIF.
      TRY .
    *     -------- create persistent send request ------------------------
          send_request = cl_bcs=>create_persistent( ).
    *     -------- create and set document with attachment ---------------
    *     create document from internal table with text
          document = cl_document_bcs=>create_document(
                        i_type    = 'RAW'
                        i_text    = mail_body_tab
                        i_subject = email_subject ).
    *     add attachment to document
          CALL METHOD document->add_attachment
            EXPORTING
              i_attachment_type    = 'PDF'
              i_attachment_subject = attachment_name
              i_att_content_hex    = content.
    *     add document to send request
          CALL METHOD send_request->set_document( document ).
    *    Set sender
          sender = cl_cam_address_bcs=>create_internet_address( sender_id ).
          CALL METHOD send_request->set_sender
            EXPORTING
              i_sender = sender.
    *     Receipients
          LOOP AT receipients_tab INTO wa_receipients .
            lv_rec = wa_receipients-receiver.
            recipient = cl_cam_address_bcs=>create_internet_address( lv_rec ).
    *       Add recipient with its respective attributes to send request
            CALL METHOD send_request->add_recipient
              EXPORTING
                i_recipient = recipient.
          ENDLOOP.
    * Set that you don't need a Return Status E-mail
          status_mail = 'N'.
          CALL METHOD send_request->set_status_attributes
            EXPORTING
              i_requested_status = 'N'
              i_status_mail      = status_mail.
    * set send immediately flag
          send_request->set_send_immediately( 'X' ).
    * Send document
          CALL METHOD send_request->send( ).
    *      COMMIT WORK.
        CATCH cx_bcs INTO bcs_exception.
          RAISE EXCEPTION bcs_exception.
    ENDTRY.
    This is in a Class which is been used in the print program for both the Output Types.
    Can somebody throw light upon this.
    Note: I tried using
    but it is not working properly.
    Thanks,
    Prashanth
    Edited by: Prashanth KR on Jan 5, 2010 6:20 AM

    Hi,
    Please paste the part of code where you are getting error.
    And if you are not clear about where the error is, try searching sdn or google with the error message that you are getting as this issue has been discussed many times earlier.
    Check this link.
    Error while opening PDF in mail attachment
    Hope it helps.
    Regards,
    Raj

  • Error while opening excel report

    Hi,
    While opening the excel report i am getting the below error.
    REP-51026: No output for job 8923
    Note: We have deployed the report in 10g Oracle Reports server present in a UNIX m/c.
    Please let me know what i have to do.
    Thanks & Regards,
    Sudhaharan.
    Message was edited by:
    jsudhaharan

    Refer Note:280376.1 on MetaLink. Hope this will help you resolve the issue.
    Thanks
    Shail

Maybe you are looking for

  • How do you know what char was deleted?

    I'm writing a GUI app that will need to keep track of opening and closing parens. It's pretty easy to Listen for when a paren is added, but I'm not sure if there a way to verify whether or not a deleted char was a paren. Does anyone know if JTextPane

  • Dma timeout

    Hello Vitaly Filatov, It looks like you did not get my response to your questions because I had some trouble loggin in to the sun forum. So I am posting it again. thanks Aspiration thank you for your response. Here is the info you wanted. On Ultra 60

  • Upgrading iLife from 04 to 08 and want Templates from the older versions

    I am upgrading Ilife 04 to 08. I want to make sure that I first keep all of the templates from the previous versions including the ones between 04 and 08. Are all old templates included with 08? If not how can I get them? i only have a disc copy of 0

  • Customizing meta data import in Flash web galley

    I'm using CS4 Bridge to create a slide show with the Journal with  Slideshow template, which captures metadata for the caption. I don't  want the image information. I want the Description field. I can manually  edit the XML file to remove it, but I w

  • Installing photoshop Cs6 trial.

    I have a folder in my desktop of photoshopCS6 but i dont knowhow to install.