Sending Excel attachment in E-mail

Hi All,
I am sending excel attachment in mail, when I see in SO01 tcode I am able to see the attachment in outbox, but getting 'Error during send Process' in sent status and not getting any mails to my e-mail id.
Could you any one help me in this?
Thanks in advance.
Vijaya.

Hi,
data: p_email   type somlreci1-receiver
                      value 'Mail ID'.
data: begin of it001 occurs 0,
      bukrs type t001-bukrs,
      butxt type t001-butxt,
      end of it001.
data:   imessage type standard table of solisti1 with header line,
        iattach type standard table of solisti1 with header line,
        ipacking_list like sopcklsti1 occurs 0 with header line,
        ireceivers like somlreci1 occurs 0 with header line,
        iattachment like solisti1 occurs 0 with header line.
start-of-selection.
  select bukrs butxt into table it001 from t001.
  Populate table with detaisl to be entered into .xls file
  perform build_xls_data .
Populate message body text
  clear imessage.   refresh imessage.
  imessage = 'Please find attached excel file'.
  append imessage.
Send file by email as .xls speadsheet
  perform send_email_with_xls tables imessage
                                      iattach
                                using p_email
                                      'Example Excel Attachment'
                                      'XLS'
                                      'TestFileName'
                                      'CompanyCodes'.
     Form  BUILD_XLS_DATA
form build_xls_data .
constants: con_cret type x value '0D',  "OK for non Unicode
            con_tab type x value '09'.   "OK for non Unicode
*If you have Unicode check active in program attributes thnen you will
*need to declare constants as follows
*class cl_abap_char_utilities definition load.
constants:
    con_tab  type c value cl_abap_char_utilities=>horizontal_tab,
    con_cret type c value cl_abap_char_utilities=>cr_lf.
  concatenate 'BUKRS' 'BUTXT'
         into iattach separated by con_tab.
  concatenate con_cret iattach into iattach.
  append  iattach.
  loop at it001 .
    concatenate it001-bukrs it001-butxt
           into iattach separated by con_tab.
    concatenate con_cret iattach  into iattach.
    append  iattach.
  endloop .
endform.
     Form  SEND_EMAIL_WITH_XLS
form send_email_with_xls tables pit_message
                                          pit_attach
                                    using p_email
                                          p_mtitle
                                          p_format
                                          p_filename
                                          p_attdescription.
  data: xdocdata like sodocchgi1,
        xcnt type i.
Fill the document data.
  xdocdata-doc_size = 1.
Populate the subject/generic message attributes
  xdocdata-obj_langu = sy-langu .
  xdocdata-obj_name  = 'SAPRPT' .
  xdocdata-obj_descr = p_mtitle .
Fill the document data and get size of attachment
  clear xdocdata.
  read table iattach index xcnt.
  xdocdata-doc_size =
     ( xcnt - 1 ) * 255 + strlen( iattach ).
  xdocdata-obj_langu  = sy-langu.
  xdocdata-obj_name   = 'SAPRPT'.
  xdocdata-obj_descr  = p_mtitle.
  clear iattachment.  refresh iattachment.
  iattachment[] = pit_attach[].
Describe the body of the message
  clear ipacking_list.  refresh ipacking_list.
  ipacking_list-transf_bin = space.
  ipacking_list-head_start = 1.
  ipacking_list-head_num = 0.
  ipacking_list-body_start = 1.
  describe table imessage lines ipacking_list-body_num.
  ipacking_list-doc_type = 'RAW'.
  append ipacking_list.
Create attachment notification
  ipacking_list-transf_bin = 'X'.
  ipacking_list-head_start = 1.
  ipacking_list-head_num   = 1.
  ipacking_list-body_start = 1.
  describe table iattachment lines ipacking_list-body_num.
  ipacking_list-doc_type   =  p_format.
  ipacking_list-obj_descr  =  p_attdescription.
  ipacking_list-obj_name   =  p_filename.
  ipacking_list-doc_size   =  ipacking_list-body_num * 255.
  append ipacking_list.
Add the recipients email address
  clear ireceivers.  refresh ireceivers.
  ireceivers-receiver = p_email.
  ireceivers-rec_type = 'U'.
  ireceivers-com_type = 'INT'.
  ireceivers-notif_del = 'X'.
  ireceivers-notif_ndel = 'X'.
  append ireceivers.
  call function 'SO_DOCUMENT_SEND_API1'
       exporting
            document_data              = xdocdata
            put_in_outbox              = 'X'
            commit_work                = 'X'
       tables
            packing_list               = ipacking_list
            contents_bin               = iattachment
            contents_txt               = imessage
            receivers                  = ireceivers
       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.
Check this Sample code.
Thanks,
Durai.V

Similar Messages

  • Generate and send Excel format file by mail in bakground.

    Hi fellows, i have a requirement, which is to generate an excel file in background and send it attached by e-mail. This file have many characteristics like Freeze pane, Auto filters, and some other format characteristics, One of the ways for achieving this kind of characteristics is using OLE or Desktop Office Integration, but both run in foreground. Other way i found is formatting the excel using XML and then at the moment of sending it by mail, changing extension for xls, but the problem is that it occupies too much space, i imagine cause it is raw xml, for example for a file for 1,000 records and 14 columns generates a file of 1.6Mb which is not like generating the same file using OLE or DOI (24Kb).
    I would like to know if there is a way to use an excel component or another way that takes less space for generating the file with format and also send it by e-mail in background??
    Thanks.
    Noe.

    is 1.6 MB the smallest size you can generate, did you remove every optional tag?
    XLSX format is a compressed XML format valid since office 2007. Maybe you can try to generate it? (I don't exactly know which ZIP algorithm it requires, SAP can compress using the ZLIB Compression Library)
    You may also attach a Windows server to SAP via RFC. You should create an RFC server. You may have a look at this [sdn article - Communication to Presentation Server in Background Mode|http://www.sdn.sap.com/irj/scn/index?rid=/library/uuid/9831750a-0801-0010-1d9e-f8c64efb2bd2] for some clues about running an RFC server. I guess you could use a VB script on the server.
    For sending emails, this is a separate question, you may have a look at wiki: sending mails - home page.

  • Sending  Excel Attachment

    Hi ,
    I am sending excel attachment through email .
    This excel attachment is generated from an ALV Grid Output .
    The excel file has all columns fixed to its initial length due to which the entire column content isnt visible unless its extended at the time of checking its content  .
    Can anyone suggest a remedy to this or send any code which can be used to read the Grid Output and Convert into excel sheet ?
    Thanks and Regards
    Soumyadip Pal

    Hi Soumyadip Pal,
    Check this code.
    REPORT z_email_abap_report.
    E-mail an Abap report                                               *
    DATA : w_name TYPE sos04-l_adr_name.
    SELECT-OPTIONS :
    Recipient address
      s_name FOR w_name DEFAULT sy-uname NO INTERVALS.
    START-OF-SELECTION.
    E-mail Abap report
      PERFORM f_send_mail.
    Form f_send_mail
    FORM f_send_mail.
    Data Declaration
      DATA:
        l_datum(10),
        ls_docdata    TYPE sodocchgi1,
        lt_objpack    TYPE TABLE OF sopcklsti1 WITH HEADER LINE,
        lt_objhead    TYPE TABLE OF solisti1   WITH HEADER LINE,
        lt_objtxt     TYPE TABLE OF solisti1   WITH HEADER LINE,
        lt_objbin     TYPE TABLE OF solisti1   WITH HEADER LINE,
        lt_reclist    TYPE TABLE OF somlreci1  WITH HEADER LINE,
        lt_listobject TYPE TABLE OF abaplist   WITH HEADER LINE,
        l_tab_lines TYPE i,
        l_att_type  LIKE soodk-objtp.
      WRITE sy-datum TO l_datum.
    List of Users According to Logon Date and Password Change
    NOTE: Create ALI/OTF Document in Spool
      SUBMIT rsusr200 WITH valid = 'X'
                      WITH notvalid = space
                      WITH unlocked = 'X'
                      WITH locked = space
                 EXPORTING LIST TO MEMORY AND RETURN.
    Read list from memory into table
      CALL FUNCTION 'LIST_FROM_MEMORY'
        TABLES
          listobject = lt_listobject
        EXCEPTIONS
          not_found  = 1
          OTHERS     = 2.
      IF sy-subrc <> 0.
      Error in function module &1
        MESSAGE ID '61' TYPE 'E' NUMBER '731'
           WITH 'LIST_FROM_MEMORY'.
      ENDIF.
    Because listobject is of size RAW(1000)
    and objbin is of size CHAR(255) we make this table copy
      CALL FUNCTION 'TABLE_COMPRESS'
        TABLES
          in             = lt_listobject
          out            = lt_objbin
        EXCEPTIONS
          compress_error = 1
          OTHERS         = 2.
      IF sy-subrc <> 0.
      Error in function module &1
        MESSAGE ID '61' TYPE 'E' NUMBER '731'
           WITH 'TABLE_COMPRESS'.
      ENDIF.
    NOTE: Creation of attachment is finished yet.
    For your report, the attachment should be placed into table
    objtxt for plain text or
    objbin for binary content.
    Now create the message and send the document.
    Create Message Body
    Title and Description
      ls_docdata-obj_name = 'USERS_LIST'.
      CONCATENATE 'List of Users' sy-sysid '-' l_datum          "#EC *
            INTO ls_docdata-obj_descr SEPARATED BY space.
    Main Text
      lt_objtxt = 'List of Users According to Logon Date' &
                  ' and Password Change'.                       "#EC *
      APPEND lt_objtxt.
    Write Packing List (Main)
      DESCRIBE TABLE lt_objtxt LINES l_tab_lines.
      READ TABLE lt_objtxt INDEX l_tab_lines.
      ls_docdata-doc_size = ( l_tab_lines - 1 ) * 255 + STRLEN( lt_objtxt ).
      CLEAR lt_objpack-transf_bin.
      lt_objpack-head_start = 1.
      lt_objpack-head_num = 0.
      lt_objpack-body_start = 1.
      lt_objpack-body_num = l_tab_lines.
      lt_objpack-doc_type = 'RAW'.
      APPEND lt_objpack.
    Create Message Attachment
    Write Packing List (Attachment)
      l_att_type = 'ALI'.
      DESCRIBE TABLE lt_objbin LINES l_tab_lines.
      READ TABLE lt_objbin INDEX l_tab_lines.
      lt_objpack-doc_size = ( l_tab_lines - 1 ) * 255 + STRLEN( lt_objbin ).
      lt_objpack-transf_bin = 'X'.
      lt_objpack-head_start = 1.
      lt_objpack-head_num = 0.
      lt_objpack-body_start = 1.
      lt_objpack-body_num = l_tab_lines.
      lt_objpack-doc_type = l_att_type.
      lt_objpack-obj_name = 'ATTACHMENT'.
      lt_objpack-obj_descr = 'List_of_Users'.                   "#EC *
      APPEND lt_objpack.
    Create receiver list
      LOOP AT s_name.
        lt_reclist-receiver = s_name-low.
        lt_reclist-rec_type = 'B'.
        APPEND lt_reclist.
      ENDLOOP.
    Send Message
      CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
        EXPORTING
          document_data              = ls_docdata
          put_in_outbox              = ''
        TABLES
          packing_list               = lt_objpack
          object_header              = lt_objhead
          contents_bin               = lt_objbin
          contents_txt               = lt_objtxt
          receivers                  = lt_reclist
        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.
      IF sy-subrc = 0.
      Document sent
        MESSAGE ID 'SO' TYPE 'S' NUMBER '022'.
      ELSE.
      Document <&> could not be sent
        MESSAGE ID 'SO' TYPE 'S' NUMBER '023'
           WITH ls_docdata-obj_name.
      ENDIF.
    ENDFORM.                               " F_SEND_MAIL
    END OF PROGRAM Z_EMAIL_ABAP_REPORT ******************
    Hope this resolves your query.
    Reward all the helpful answers.
    Regards

  • Send excel attachment using FM SO_NEW_DOCUMENT_ATT_SEND_API1

    Hi ABAPers,
    I managed to send excel attachment using FM SO_NEW_DOCUMENT_ATT_SEND_API1.
    Let say I send it to my own email account.
    But, when try to open the excel document, from lotus notes, there is warning message produced by the microsoft excel saying:
    "The file is not in a recognizable format.
    and so on....."
    Anyway, when I click button 'OK', excel sheet will be opened and no information lost.
    How can we code the abap program so that the message will not come each time I open the attachment from my lotus notes?
    Or this is just the tab delimited issue?
    Thank you.
    Regards,
    Edward.

    Hi Shan,
    Thank you for replying.
    I have the same as follows:
      DESCRIBE TABLE lt_contents_hex LINES lv_lines.
      lt_packing_list-transf_bin = 'X'.
      lt_packing_list-head_start = 1.
      lt_packing_list-head_num   = 1.
      lt_packing_list-body_start = 1.
      lt_packing_list-body_num   = lv_lines.
      lt_packing_list-doc_type   = 'XLS'.
      lt_packing_list-obj_name   = 'ATTACHMENT'.
      lt_packing_list-obj_descr  = 'Attachment'.
      lt_packing_list-doc_size   = lv_lines * 255.
      APPEND lt_packing_list.
    I'm using lt_contents_hex instead of lt_contents_bin.
    Still the problem is there.
    Is there any other way to calculate the doc size correctly?
    Regards,
    Edward.

  • Since installing 8.0.1 I cannot send an attachment in AOL mail when I could with previous versions.

    When I try to send an attachment in AOL mail I get an error message "We encountered a technical issue, please try again."
    This happens every time over the past few days.

    Never mind the above message....I uninstalled Firefox 4.0.1 and reinstalled 3.6 and then updated to 3.6.7. Now I've lost all my Bookmarks. This is really getting to be frustrating and ridiculously hard to find answers!! What's up with the brains behind Mozilla?? Are they all hacked??

  • Sending an Excel Attachment in E-mail, where linesize 255 characters

    Hi,
    I have a requirement where I need to send an Excel attachment of around 150 columns and the line-size is around 2000 characters.
    I was planning to use SO_DOCUMENT_SEND_API1.
    But, it appears that because of the restriction of 255 characters as SOLISTI1 structure has the field size of 255 characters.
    Please note, I cannot use any of the OLE or foreground Excel functions, as the job runs in the background.
    Please let me know if you have any solutions or work around.
    Hoiping to hear from all of the experts out there.
    Regards,
    Ani

    try to use the following classes :       
    send_request  TYPE REF TO cl_bcs,
            document      TYPE REF TO cl_document_bcs,
            conlengths    TYPE        so_obj_len,
            html          TYPE STANDARD TABLE OF w3html,
            sender_id     TYPE REF TO if_sender_bcs,
            recipient     TYPE REF TO if_recipient_bcs,
            sent_to_all   TYPE        os_boolean,
            bcs_exception TYPE REF TO cx_bcs,
            bcs_message   TYPE        string.

  • Error while sending Excel attachment thro FM 'SO_NEW_DOCUMENT_ATT_SEND_API1

    Experts:
    I am working on sending Excel as an email attachment thro the function module 'SO_NEW_DOCUMENT_ATT_SEND_API1'
    I am able to send mail successfully but I face the following two issues while opening the attachment.
    1. While opening it says 'un recognized format' , on pressing 'OK' it opens the excel file.
    2. The column heading (first row) which should be in Korean character is displayed in junk char. I tried to
        specify the unicode (Code Page = '8500')  but does not know how to do it.
        I am reading the column header text from standard text.
    Please let me know what mistake I have commited in my code and where I should specify the unicode transformation. I refered many samples but could not make it.
    Please let me know the error.
    The code is as follows.
    FORM sendemail_barcodedata.
      TYPE-POOLS: truxs.
      DATA: objpack LIKE sopcklsti1 OCCURS 2  WITH HEADER LINE.
      DATA: objhead LIKE solisti1   OCCURS 1  WITH HEADER LINE.
      DATA: objbin  LIKE solisti1   OCCURS 10 WITH HEADER LINE.
      DATA: objbin1 LIKE solisti1   OCCURS 10 WITH HEADER LINE.
      DATA: objtxt  LIKE solisti1   OCCURS 10 WITH HEADER LINE.
      DATA: reclist LIKE somlreci1  OCCURS 5  WITH HEADER LINE.
      DATA: doc_chng LIKE sodocchgi1.
      DATA: tab_lines LIKE sy-tabix.
      DATA: l_sent_to_all  TYPE sonv-flag.
    * Creating the document to be sent
    * File Name
      doc_chng-obj_name  = 'BCODEINFO'.
    * Mail Subject
      doc_chng-obj_descr = 'Delivery Barcode Information'.
    * Mail Content
      objtxt = 'Hi:'.
      APPEND objtxt.
      objtxt = 'Find attached,  Delivery Barcode Information'.
      APPEND objtxt.
      CONCATENATE 'Attachment : <<' w_fname1 '>>' INTO objtxt.
      APPEND objtxt.
      DESCRIBE TABLE objtxt LINES tab_lines.
      READ TABLE objtxt INDEX tab_lines.
      doc_chng-doc_size = ( tab_lines - 1 ) * 255 + STRLEN( objtxt ).
      doc_chng-obj_langu = sy-langu.
      doc_chng-sensitivty = 'F'.
    * Creating the entry for the compressed document
      CLEAR objpack-transf_bin.
      objpack-head_start = 1.
      objpack-head_num   = 0.
      objpack-body_start = 1.
      objpack-body_num   = tab_lines.
      objpack-doc_type   = 'RAW'.
      APPEND objpack.
    * Creating the document attachment
    * Get column names for Barcode Data
      CLEAR objbin.
      CONCATENATE text-h23
                  text-h24
                  text-h25
                  text-h26
                  text-h27
                  INTO  objbin  SEPARATED BY con_tab .
      CONCATENATE objbin con_cret INTO objbin.
      APPEND objbin.
      CLEAR objbin.
      LOOP AT it_excel2 INTO wa_excel2.
        CONCATENATE wa_excel2-zz_date
                    wa_excel2-zz_delivery
                    wa_excel2-zz_barcode
                    wa_excel2-blank1
                    wa_excel2-blank2
                    INTO objbin  SEPARATED BY con_tab.
        CONCATENATE objbin con_cret INTO objbin.
        APPEND objbin.
        CLEAR objbin.
      ENDLOOP.
      DESCRIBE TABLE objbin LINES tab_lines.
      objhead = w_fname1.
      APPEND objhead.
    * Creating the entry for the compressed attachment
      objpack-transf_bin = 'X'.
      objpack-head_start = 1.
      objpack-head_num   = 1.
      objpack-body_start = 1.
      objpack-body_num   = tab_lines.
      objpack-doc_type   = 'XLS'.
      objpack-obj_name   = 'Barcode Information'.
      objpack-obj_descr  = 'Barcode Information'.
      objpack-doc_size   = tab_lines * 255.
      APPEND objpack.
    * Entering names in the distribution list
      reclist-receiver = p_email.
      reclist-rec_type = 'U'.
      APPEND reclist.
    * Sending the document
      CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
        EXPORTING
          document_data              = doc_chng
          put_in_outbox              = ' '
          commit_work                = 'X'
        IMPORTING
         sent_to_all                 = l_sent_to_all
        TABLES
          packing_list               = objpack
          object_header              = objhead
          contents_bin               = objbin
          contents_txt               = objtxt
          receivers                  = reclist
        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.
      CASE sy-subrc.
        WHEN 0.
          MESSAGE i000(z65f_msgclass) WITH text-211.
        WHEN 1.
          WRITE: / 'no authorization to send to the specified number of'.
        WHEN 2.
          WRITE: / 'document could not be sent to any of the recipients!'.
        WHEN 4.
          WRITE: / 'no authorization to send !'.
        WHEN OTHERS.
          WRITE: / 'error occurred during sending !'.
      ENDCASE.
    ENDFORM.                 
    Thanks in advance.
    Regards
    Vijai

    Hi:
    Can any one provide me a solution for this?
    regards
    vijai

  • Excel Attachment Problem in Mail box

    Hi All,
    I had program in which i am sending mail along with Excel attachment using FM SO_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 "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". 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'.
    Can someone help me on this ?
    Thanks,
    Praveen

    Hi,
    With the Module , you can check this-
    Hope this link may help you-
    Body and Attachment both in a mail
    Idoc to a flatfile and then email it as an attachment
    Regards,
    Moorthy

  • Excel Attachment in E-mail

    Hi,
    My requiremnt is to attach an excel file in the e-mail which will be triggered through an output type while saving the RFQ document.
    This excel attachment will have the item details. And some of the columns in the excel attachment needs to be protected(Non editable mode) and the structure also be protected
    Please help me out in this.

    this is a simple example for sending the excel with attachment..
    REPORT  ZMAIL.
    TABLES: ekko.
    PARAMETERS: p_email   TYPE somlreci1-receiver .
    (here give the email id)
    TYPES: BEGIN OF t_ekpo,
      ebeln TYPE ekpo-ebeln,
      ebelp TYPE ekpo-ebelp,
      aedat TYPE ekpo-aedat,
      matnr TYPE ekpo-matnr,
    END OF t_ekpo.
    DATA: it_ekpo TYPE STANDARD TABLE OF t_ekpo INITIAL SIZE 0,
          wa_ekpo TYPE t_ekpo.
    TYPES: BEGIN OF t_charekpo,
      ebeln(10) TYPE c,
      ebelp(5)  TYPE c,
      aedat(8)  TYPE c,
      matnr(18) TYPE c,
    END OF t_charekpo.
    DATA: wa_charekpo TYPE t_charekpo.
    DATA:   it_message TYPE STANDARD TABLE OF solisti1 INITIAL SIZE 0
                    WITH HEADER LINE.
    DATA:   it_attach TYPE STANDARD TABLE OF solisti1 INITIAL SIZE 0
                    WITH HEADER LINE.
    DATA:   t_packing_list LIKE sopcklsti1 OCCURS 0 WITH HEADER LINE,
            t_contents LIKE solisti1 OCCURS 0 WITH HEADER LINE,
            t_receivers LIKE somlreci1 OCCURS 0 WITH HEADER LINE,
            t_attachment LIKE solisti1 OCCURS 0 WITH HEADER LINE,
            t_object_header LIKE solisti1 OCCURS 0 WITH HEADER LINE,
            w_cnt TYPE i,
            w_sent_all(1) TYPE c,
            w_doc_data LIKE sodocchgi1,
            gd_error    TYPE sy-subrc,
            gd_reciever TYPE sy-subrc.
    *START_OF_SELECTION
    START-OF-SELECTION.
      Retrieve sample data from table ekpo
      PERFORM data_retrieval.
      Populate table with detaisl to be entered into .xls file
      PERFORM build_xls_data_table.
    *END-OF-SELECTION
    END-OF-SELECTION.
    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 p_email
                                          'Example .xls documnet attachment'
                                          'XLS'
                                          'filename'
                                 changing gd_error
                                          gd_reciever.
      Instructs mail send program for SAPCONNECT to send email(rsconn01)
      PERFORM initiate_mail_execute_program.
    *&      Form  DATA_RETRIEVAL
          Retrieve data form EKPO table and populate itab it_ekko
    FORM data_retrieval.
      SELECT ebeln ebelp aedat matnr
       UP TO 10 ROWS
        FROM ekpo
        INTO TABLE it_ekpo.
    ENDFORM.                    " DATA_RETRIEVAL
    *&      Form  BUILD_XLS_DATA_TABLE
          Build data table for .xls document
    FORM build_xls_data_table.
      data: ld_store(50) type c.  "Leading zeros
      CONSTANTS: con_cret(5) TYPE c VALUE '0D',  "OK for non Unicode
                 con_tab(5) TYPE c VALUE '09'.   "OK for non Unicode
    *If you have Unicode check active in program attributes thnen you will
    *need to declare constants as follows
    *class cl_abap_char_utilities definition load.
    *constants:
       con_tab  type c value cl_abap_char_utilities=>HORIZONTAL_TAB,
       con_cret type c value cl_abap_char_utilities=>CR_LF.
      CONCATENATE 'EBELN' 'EBELP' 'AEDAT' 'MATNR' INTO it_attach SEPARATED BY con_tab.
      CONCATENATE con_cret it_attach  INTO it_attach.
      APPEND  it_attach.
      LOOP AT it_ekpo INTO wa_charekpo.
    *Modification to retain leading zeros
      inserts code for excell REPLACE command into ld_store
      =REPLACE("00100",1,5,"00100")
        concatenate '=REPLACE("' wa_charekpo-ebelp '",1,5,"'
                                 wa_charekpo-ebelp '")' into ld_store .
      concatenate ld_store into .xls file instead of actual value(ebelp)
        CONCATENATE wa_charekpo-ebeln ld_store  wa_charekpo-aedat wa_charekpo-matnr  INTO it_attach SEPARATED BY con_tab.
        CONCATENATE con_cret it_attach  INTO it_attach.
        APPEND  it_attach.
      ENDLOOP.
    ENDFORM.                    " BUILD_XLS_DATA_TABLE
    *&      Form  SEND_FILE_AS_EMAIL_ATTACHMENT
          Send email
    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.
      DATA: ld_error    TYPE sy-subrc,
            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.
      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.
      READ TABLE it_attach INDEX w_cnt.
      w_doc_data-doc_size =
         ( w_cnt - 1 ) * 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.
      t_receivers-receiver = ld_email.
      t_receivers-rec_type = 'U'.
      t_receivers-com_type = 'INT'.
      t_receivers-notif_del = 'X'.
      t_receivers-notif_ndel = 'X'.
      APPEND t_receivers.
      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.
    *&      Form  INITIATE_MAIL_EXECUTE_PROGRAM
          Instructs mail send program for SAPCONNECT to send email.
    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
    *&      Form  POPULATE_EMAIL_MESSAGE_BODY
           Populate message body text
    form populate_email_message_body.
      REFRESH it_message.
      it_message = 'Please find attached a list test ekpo records'.
      APPEND it_message.
    endform.                    " POPULATE_EMAIL_MESSAGE_BODY
    regards,
    venkat

  • How to send multiple attachements in single mail

    Hi All,
    Currently i am using this function module SO_NEW_DOCUMENT_ATT_SEND_API1 to send mail with only one attachment.
    But now i need to send multiple attachments to a single mail.
    Can any one please tell me as how to send multiple attachments in single mail.
    Thanks in advance.

    Hi
    See this and do accordingly
    Mailing with Attachment by ABAP Coding  
    Refer this link:
    Mail with attachment.
    FORM send_list_to_basis .
      DATA: w_path      LIKE rlgrap OCCURS 0 WITH HEADER LINE,
            lt_index    TYPE sy-tabix,
            doc_type(3) TYPE c,
            descr       LIKE it_objpack_basis-obj_descr,
            temp_data   LIKE w_path,
            temp1       TYPE string,
            tab_lines   TYPE i,
            langu(15)   TYPE c,
            expirydate  TYPE so_obj_edt,
            L_FILE1(100).
      CONCATENATE 'C:\' sy-repid '_' sy-datum '.XLS' INTO L_FILE1.
      W_PATH-FILENAME = L_FILE1.
      APPEND w_path.
      CLEAR w_path.
      wa_doc_chng-obj_descr  = 'User List not logged on for 180 days'.
      wa_doc_chng-obj_langu  = 'E'.
      wa_doc_chng-obj_expdat = sy-datum.
      CLEAR w_subject.
      CONCATENATE 'Please find attached document with list of users'
                  'not logged on for 180 days for client' sy-mandt
                  INTO w_subject SEPARATED BY space.
      it_objtxt_basis-line = w_subject.
      APPEND it_objtxt_basis.
      CLEAR it_objtxt_basis.
      it_objtxt_basis-line = text-004.
      APPEND it_objtxt_basis.
      CLEAR it_objtxt_basis.
      CLEAR w_tab_line.
      DESCRIBE TABLE it_objtxt_basis LINES w_tab_line.
      READ TABLE it_objtxt_basis INDEX w_tab_line  INTO l_cline.
      wa_doc_chng-doc_size =
       ( w_tab_line - 1 ) * 255 + STRLEN( l_cline ).
      CLEAR it_objpack_basis-transf_bin.
      it_objpack_basis-head_start = 1.
      it_objpack_basis-head_num   = 0.
      it_objpack_basis-body_start = 1.
      it_objpack_basis-body_num   = w_tab_line.
      it_objpack_basis-doc_type   = 'RAW'.
      APPEND it_objpack_basis.
      CLEAR it_objpack_basis.
      LOOP AT w_path.
        temp1 = w_path.
        descr = w_path.
        CALL FUNCTION 'STRING_REVERSE'
          EXPORTING
            string  = descr
            lang    = 'E'
          IMPORTING
            rstring = descr.
        CALL FUNCTION 'STRING_SPLIT'
          EXPORTING
            delimiter = '\'
            string    = descr
          IMPORTING
            head      = descr
            tail      = temp_data.
        CALL FUNCTION 'STRING_REVERSE'
          EXPORTING
            string  = descr
            lang    = 'E'
          IMPORTING
            rstring = descr.
        CALL FUNCTION 'STRING_SPLIT'
          EXPORTING
            delimiter = '.'
            string    = descr
          IMPORTING
            head      = temp_data
            tail      = doc_type.
        CALL FUNCTION 'GUI_UPLOAD'
          EXPORTING
            filename      = temp1
            filetype      = 'BIN'
            header_length = 0
            read_by_line  = 'X'
            replacement   = '#'
          TABLES
            data_tab      = it_upload.
        DESCRIBE TABLE it_upload LINES tab_lines.
        DESCRIBE TABLE it_objbin_basis LINES lt_index.
        lt_index = lt_index + 1.
        LOOP AT it_upload.
          wa_objbin_basis-line = it_upload-line.
          APPEND wa_objbin_basis TO it_objbin_basis.
          CLEAR wa_objbin_basis.
        ENDLOOP.
        it_objpack_basis-transf_bin = 'X'.
        it_objpack_basis-head_start = 0.
        it_objpack_basis-head_num   = 0.
        it_objpack_basis-body_start = lt_index.
        it_objpack_basis-body_num   = tab_lines.
        it_objpack_basis-doc_type   = doc_type.
        it_objpack_basis-obj_descr  = descr.
        it_objpack_basis-doc_size   = tab_lines * 255.
        APPEND it_objpack_basis.
        CLEAR it_objpack_basis.
      ENDLOOP.
      it_reclist_basis-receiver = '[email protected]'.
      it_reclist_basis-rec_type = 'U'.
      APPEND it_reclist_basis.
      CLEAR it_reclist_basis.
      CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
        EXPORTING
          document_data              = wa_doc_chng
          put_in_outbox              = 'X'
          commit_work                = 'X'
        TABLES
          packing_list               = it_objpack_basis
          contents_txt               = it_objtxt_basis
          contents_bin               = it_objbin_basis
          receivers                  = it_reclist_basis
        EXCEPTIONS
          too_many_receivers         = 1
          document_not_sent          = 2
          operation_no_authorization = 4
          OTHERS                     = 99.
      IF sy-subrc EQ 0.
        SUBMIT rsconn01 WITH mode = 'INT' AND RETURN.
      ENDIF.
    ENDFORM.                    " send_list_to_basis
    <b>Reward points for useful Answers</b>
    Regards
    Anji

  • Send excel attachment with more than 255 characters in the internal table

    Hi,
    I need to send an attachment in the form of spreadsheet.
    But the internal table that is being used for sending attachment in mails can have only 255 characters in one row.
    Whereas my spreadsheet requires a greater width than 255 characters .

    Hi,
    I need to send an attachment in the form of spreadsheet.
    But the internal table that is being used for sending attachment in mails can have only 255 characters in one row.
    Whereas my spreadsheet requires a greater width than 255 characters .

  • Excel attachment in a mail for background program

    Hi,
    I have a program which is scheduled to execute in background every day.
    Program output is printed to the screen. Simultaneously, I want to send an excel file as an attachment through email.
    This excel file would be having the same data which is printed on the screen.
    I have checked for other threads  in SDN for sending excel file as attachment, but did not find anything relavant.
    If anyone has any idea, please let me know....
    Thanks in advance - S M

    Hi,
    You can use the cl_bcs class to send email with attachments.
    Refer to the below article of mine which has the code snippet on how to send an excel file as an attachement.
    http://divulgesap.com/blog.php?p=ODI=
    Hope it helps.
    Regards,
    Ravikiran

  • Send few attachment at one mail via Abap

    Hi.
    How can send few attachments in one mail threw Abap?
    I know how to send files but how can I attach few files in one mail ?
    Thanks all,
    Rebeka

    Hi,
    Tthe following piece of logic is required to send multiple attachments in one mail.
    Loop
    * Creating the entry for the compressed attachment
            IF gv_count = 1.
              gi_objpack-head_start = 1.
              gi_objpack-head_num   = 1.
              gi_objpack-body_start = 1.
              DESCRIBE TABLE gi_objbin LINES gv_no_lines.
              gi_objpack-body_num   = gv_no_lines.
              gi_objpack-doc_size   = gv_no_lines * 255.
              gi_objpack-transf_bin = gc_x.
              gi_objpack-doc_type   = gc_pdf.
              gi_objpack-obj_name   = text-037.
              CONCATENATE text-038 gw_doc_id-object_id(10)
              INTO gi_objpack-obj_descr.
              APPEND gi_objpack.
            ELSEIF gv_count > 1.
              gi_objpack-head_start = gv_no_lines + 1.
              gi_objpack-head_num   = gv_no_lines + 1.
              gi_objpack-body_start = gv_no_lines + 1.
              DESCRIBE TABLE gi_upload LINES gv_no_lines.
              gi_objpack-body_num   = gv_no_lines.
              gi_objpack-doc_size   = gv_no_lines * 255.
              gi_objpack-transf_bin = gc_x.
              gi_objpack-doc_type   = gc_pdf.
              gi_objpack-obj_name   = text-037.
              CONCATENATE text-038 gw_doc_id-object_id(10)
              INTO gi_objpack-obj_descr.
              APPEND gi_objpack.
              DESCRIBE TABLE gi_objbin LINES gv_no_lines.
            ENDIF.
      Endloop.
    Each record in gi_objpack is an attachment, say suppose 3 records are there, then it means 3 attachments.
    gi_objbin is the attachment content, here it is a PDF File.
    Hope u know about this FM 'SO_NEW_DOCUMENT_ATT_SEND_API1' and remaining details to pass to this FM.
    Thanks,
    Srilakshmi.

  • Send EXCEL attachment with garbage russia text

    Hello All - Good day!
    I have the same problem where non-english text like russian, and will appear garbage in the excel attachment after it was email.
    When I test it in english description/text it looks ok.
    I have tried the following FM, and got no luck.
    CALL FUNCTION 'SO_DOCUMENT_SEND_API1'
    CALL FUNCTION 'SO_NEW_DOCUMENT_SEND_API1'
    CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
    Program is in Unicode.
    PLEASE help.

    Hello,
    Check the following SAP note in this regards:
      1151258 Error when sending Excel attachments
    Also, please check SAP note regarding SO_DOCUMENT_SEND_API1 interface:
       190669 Sending lists via SAPconnect
    Regards,
    David

  • Signatures disappear when sending file attachment in iPad Mail

    Whenever I send an attachment from GoodReader or Pages the file appears at the bottom of the message and my default signature disappears.  How can I send files with a signature?

    Hi,
    Attachment Content is not Mandatory to enter unless you wish to override the Attachment Property.
    Basically we use this content along with Encoded Image Property like chart, spc and image loader action block.
    If you are loading file from system using Proper path in Attachment Section then no need to use Attachment Content section.
    Ensure that you have set the Attachment Content Type to "application/pdf" to send pdf files and a valid File path in Attachment section.
    Hope this helps!!
    Regards,
    Adarsh

Maybe you are looking for

  • Importing CD to desktop via iTunes for mp3?

    Is there a simple way to import CD's on a Mac to say a desktop folder, that converts them all to 192K mp3? I'm assuming this would involve doing this through iTunes? Or is there a simple way on OS X to import direct to mp3 to a folder? Thanks

  • Stream Netflix to TV issue

    I used the Apple composite AV cable to play my iTunes movies from iPad 2 to my TV; it worked just fine. But now I can't get the video to show up when I try to watch Netflix videos. I only hear the audio and the video just plays on the iPad rather tha

  • Help: My boss is considering downgrading to CS2

    We are currently using CS3 and my boss is considering a downgrade to CS2 for reasons other than CS3 features. I need to defend my teams corner and defend the use of CS3, by supplying info about how some effects and appearances might not survive the (

  • Old Library New iphoto

    I had my old iphoto library on an external hard drive (someone set that up for me and I'm not sure how he did it) I just got iLife '08. What's the best way to import my old Library into my new iphoto? Thanks!

  • Set File Open dialog path in Acrobat

    Hi forum, Is there a way to set the path for the File Open dialog that shows in Acrobat? The situation I have is that the navigation up and down folders to Watermarks and files to be inserted is a painful process. I would like to add buttons to the a