Sending a excel sheet as attachment in mail

Hi,
I have requirement where I need to send excel sheet as attachment in mail. I could do it by using FM SO_NEW_DOCUMENT_ATT_SEND_API1. But, I am not able to format the excel sheet before sending.
I need to make heading bold, fix column width and wrap text in some cells, and send the mail.
Pls help me with your suggestions.
Thanks,
Siva.

this link will show you how to do formatting in Excel using the OLE method, then use that EXCEL to send the MAIL using your program \
[OLE-format excel |http://www.sap-img.com/abap/download-to-excel-with-format-border-color-cell-etc.htm]
Hope That Helps
Anirban M.

Similar Messages

  • Error while sending excel sheet as attachment to Mail Receiver

    Hi everyone,
    I am facing the below error when I am trying to send data to Mail receiver adapter. The attachment is excel sheet.
    Delivery of the message to the application using connection Mail_http://sap.com/xi/XI/System failed, due to: com.sap.aii.af.ra.ms.api.RecoverableException: Object not found in lookup of MessageTransformBean.: com.sap.engine.services.jndi.persistent.exceptions.NameNotFoundException: Object not found in lookup of MessageTransformBean..
    I don't understand where the problem is. This has been running since long time and last month we have changed our web dispatcher details. I hope everything is fine. But not sure the root cause for this issue.
    Please help me in resolving this.
    Thank you.
    Regards
    Bhanu T.

    Check if this helps: MessageTransformBean module
    Confirm that you have configured the MessagetransformationBean properly.
    Are you trying to convert some payload into Excel and send it as an attachment in the Mail CC? If yes, then I hope that you have included the correct Content_type value.
    Check this for more info on Content_type: /people/community.user/blog/2006/09/08/email-report-as-attachment-excelword
    Regards,
    Abhishek.

  • Sending an excel sheet of  to mail Ids using file to mail scenario

    Hello,
    I have a folder with three folders archive exception and log. Log folders have the details of exception. I want the XML files that are in Exception, to be sent to resp email ids with the data in it to be stored in an excel sheet( data will be collected from the log file for the correspondng file in exception).
    eg: if test.xml is in exception its log will have an exception detail somethng like " Enter a value".
    In this case i want to give the exception details as well as some relevant details with it like material number etc , time at which the exception occured . These details are to be given in an excel sheet .
    Is it possible to do using file to mail scenario. Please help by explianing the procedure.
    Regards.

    This can be done with the help of some Java and ABAP coding. I can give you a general view on how to do this.
    1. Configure a file adapter for sender to pick up the exception files.
    2. While doing the mapping, create a UDF to store the values (which you need to send it to excel file) in a table in ABAP Stack.
    3. Create a ABAP Program in R3 (which can be schedule on regular intervals depending on ur req) to create an excel sheet based on the the data in the table (created in previous step). I am not sure how easy to code ABAP program to create an excel sheet.
    4. Create one more file adapter to send this excel sheet to the corresponding mail ids.
    This is a very high level view on doing this.

  • Excel file as attachment in mail

    Hi Friends,
    I have a requirement of sending th Excel sheet through email attachment.
    I am getting the records into the internal table,but after sending the Email and receiving it the first line in the excel sheet is a blank line.
    Can you please provide me a solution with source code.

    Hi Pooja,
    check thios code...hope it helps
    *& Report ZWBSAP_EMAIL *
    *Send an email via SAP Workplace
    *Select files from SAP server
    *Note:
    Uses custom table zlookup to pick up a group of email addresses to send to
    if more than one is needed.
    Please note some hard coding.
    REPORT zsap_email MESSAGE-ID z001.
    TABLES: rlgrap, btcxpm, zlookup.
    DATA:
    v_zcode(3) TYPE c,
    svrname LIKE zlookup-zdesc,
    wa_error(80) TYPE c,
    global_filemask_all(80).
    DATA: t_soud LIKE soud.
    DATA: p_infolder LIKE sofdk.
    DATA: p_outfolder LIKE sofdk.
    DATA: object_hd_display LIKE sood2.
    DATA: object_id LIKE soodk.
    DATA: document LIKE sood4.
    DATA: header_data LIKE sood2.
    DATA: link_folder_id LIKE soodk.
    DATA: folder_selections LIKE sofds.
    DATA: folder_list LIKE soxli OCCURS 0 WITH HEADER LINE.
    DATA: receivers LIKE soos1 OCCURS 0 WITH HEADER LINE.
    DATA: objcont LIKE soli OCCURS 0 WITH HEADER LINE.
    DATA: objhead LIKE soli OCCURS 0 WITH HEADER LINE.
    DATA: object_content LIKE solisti1 OCCURS 0 WITH HEADER LINE.
    DATA: object_hd_change LIKE sood1.
    DATA: BEGIN OF files OCCURS 0,
    line(200) TYPE c,
    END OF files.
    DATA: listobject LIKE abaplist OCCURS 1 WITH HEADER LINE.
    *Email to addresses
    SELECTION-SCREEN: BEGIN OF BLOCK bl1 WITH FRAME TITLE text-bl1.
    PARAMETERS: p_mailto(240) TYPE c.
    SELECTION-SCREEN SKIP 1.
    SELECTION-SCREEN COMMENT 10(2) text-001.
    *Use zlookup-ztype as group to define multiple email to addresses
    SELECT-OPTIONS: s_mailto FOR zlookup-ztype.
    SELECTION-SCREEN: END OF BLOCK bl1.
    *Subject
    SELECTION-SCREEN: BEGIN OF BLOCK bl2 WITH FRAME TITLE text-bl2.
    PARAMETERS: p_subj LIKE document-objdes.
    SELECTION-SCREEN: END OF BLOCK bl2.
    *Body
    SELECTION-SCREEN: BEGIN OF BLOCK bl3 WITH FRAME TITLE text-bl3.
    PARAMETERS: p_body1 LIKE solisti1-line LOWER CASE.
    PARAMETERS: p_body2 LIKE solisti1-line LOWER CASE.
    PARAMETERS: p_body3 LIKE solisti1-line LOWER CASE.
    PARAMETERS: p_body4 LIKE solisti1-line LOWER CASE.
    PARAMETERS: p_body5 LIKE solisti1-line LOWER CASE.
    PARAMETERS: p_body6 LIKE solisti1-line LOWER CASE.
    SELECTION-SCREEN: END OF BLOCK bl3.
    *Attachments
    SELECTION-SCREEN: BEGIN OF BLOCK bl4 WITH FRAME TITLE text-bl4.
    PARAMETERS: p_fname1 LIKE files-line.
    PARAMETERS: p_fname2 LIKE files-line.
    PARAMETERS: p_fname3 LIKE files-line.
    PARAMETERS: p_fname4 LIKE files-line.
    PARAMETERS: p_fname5 LIKE files-line.
    PARAMETERS: p_fname6 LIKE files-line.
    SELECTION-SCREEN: END OF BLOCK bl4.
    AT SELECTION-SCREEN.
    PERFORM chk_selection.
    IF NOT wa_error IS INITIAL.
    MESSAGE e001 WITH wa_error.
    ENDIF.
    START-OF-SELECTION.
    END-OF-SELECTION.
    PERFORM send_email.
    FORM chk_selection *
    FORM chk_selection.
    CLEAR wa_error.
    *Loop only once ???
    *If more checkings to be done.
    *Think about it and if not clear.
    *Let it sink in for a couple of minutes.
    *Still doesn't make sence? Go home and sleep on it.
    DO 1 TIMES.
    *Check Email to
    IF p_mailto IS INITIAL
    AND s_mailto IS INITIAL.
    wa_error = 'Invalid or no EMAIL TO selection'.
    EXIT.
    ENDIF.
    ENDDO.
    ENDFORM.
    *& Form send_email
    text
    --> p1 text
    <-- p2 text
    FORM send_email.
    PERFORM get_folder_info.
    PERFORM fill_body.
    PERFORM ins_new_object.
    PERFORM crt_attachments.
    PERFORM fill_receivers_info.
    PERFORM snd_email.
    ENDFORM. " send_email
    FORM Get_folder_info *
    FORM get_folder_info.
    CLEAR t_soud.
    *Small so should be quick.
    SELECT * FROM soud
    INTO t_soud
    WHERE sapnam = sy-uname.
    p_infolder-foltp = 'FOL'.
    p_infolder-folyr = t_soud-inbyr. "inbox
    p_infolder-folno = t_soud-inbno.
    p_outfolder-foltp = 'FOL'.
    p_outfolder-folyr = t_soud-outyr. "outbox
    p_outfolder-folno = t_soud-outno.
    ENDSELECT.
    ENDFORM.
    FORM fill_body *
    FORM fill_body.
    object_content-line = p_body1.
    APPEND object_content.
    object_content-line = p_body2.
    APPEND object_content.
    object_content-line = p_body3.
    APPEND object_content.
    object_content-line = p_body4.
    APPEND object_content.
    object_content-line = p_body5.
    APPEND object_content.
    object_content-line = p_body6.
    APPEND object_content.
    ENDFORM.
    FORM ins_new_object *
    FORM ins_new_object.
    object_hd_change-objnam = 'Notes'.
    object_hd_change-objdes = p_subj.
    CALL FUNCTION 'SO_OBJECT_INSERT'
    EXPORTING
    folder_id = p_outfolder
    object_hd_change = object_hd_change
    object_type = 'RAW'
    owner = sy-uname
    IMPORTING
    object_hd_display = object_hd_display
    object_id = object_id
    TABLES
    objcont = object_content
    objhead = objhead
    EXCEPTIONS
    active_user_not_exist = 1
    communication_failure = 2
    component_not_available = 3
    dl_name_exist = 4
    folder_not_exist = 5
    folder_no_authorization = 6
    object_type_not_exist = 7
    operation_no_authorization = 8
    owner_not_exist = 9
    parameter_error = 10
    substitute_not_active = 11
    substitute_not_defined = 12
    system_failure = 13
    x_error = 14
    OTHERS = 15.
    IF sy-subrc 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
    WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    ENDIF.
    ENDFORM.
    FORM crt_attachments *
    --> P_SUBJ *
    FORM crt_attachments.
    document-foltp = p_outfolder-foltp.
    document-folyr = p_outfolder-folyr.
    document-folno = p_outfolder-folno.
    document-objtp = object_id-objtp.
    document-objyr = object_id-objyr.
    document-objno = object_id-objno.
    document-objnam = 'Notes'.
    document-objdes = p_subj.
    document-okcode = 'CHNG'.
    document-file_ext = 'TXT'.
    link_folder_id = object_id.
    header_data-objla = 'EN'.
    header_data-objnam = document-objnam.
    header_data-objdes = document-objdes.
    header_data-objpri = '5'.
    header_data-objsns = 'O'.
    header_data-file_ext = 'TXT'.
    REFRESH files.
    CLEAR files.
    IF NOT p_fname1 IS INITIAL.
    files-line = p_fname1.
    APPEND files.
    ENDIF.
    IF NOT p_fname2 IS INITIAL.
    files-line = p_fname2.
    APPEND files.
    ENDIF.
    IF NOT p_fname3 IS INITIAL.
    files-line = p_fname3.
    APPEND files.
    ENDIF.
    IF NOT p_fname4 IS INITIAL.
    files-line = p_fname4.
    APPEND files.
    ENDIF.
    IF NOT p_fname5 IS INITIAL.
    files-line = p_fname5.
    APPEND files.
    ENDIF.
    IF NOT p_fname6 IS INITIAL.
    files-line = p_fname6.
    APPEND files.
    ENDIF.
    IF NOT files[] IS INITIAL.
    CALL FUNCTION 'SO_DOCUMENT_REPOSITORY_MANAGER'
    EXPORTING
    method = 'ATTCREATEFROMPC'
    TABLES
    files = files
    CHANGING
    document = document
    header_data = header_data.
    IF sy-subrc = 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
    WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    ENDIF.
    ENDIF.
    ENDFORM.
    FORM fill_receivers_info *
    FORM fill_receivers_info.
    DATA: BEGIN OF reclist OCCURS 0,
    rec LIKE receivers-recextnam,
    END OF reclist.
    *Build reclist
    REFRESH reclist.
    IF NOT p_mailto IS INITIAL.
    reclist-rec = p_mailto.
    APPEND reclist.
    ENDIF.
    IF NOT s_mailto IS INITIAL.
    SELECT zdesc
    INTO reclist-rec
    FROM zlookup
    WHERE ztype IN s_mailto.
    APPEND reclist.
    ENDSELECT.
    ENDIF.
    REFRESH receivers.
    LOOP AT reclist.
    folder_selections-folnam = 'INBOX'.
    CALL FUNCTION 'SO_FOLDER_LIST_READ'
    EXPORTING
    folder_selections = folder_selections
    owner = sy-uname
    region = 'P'
    TABLES
    folder_list = folder_list
    EXCEPTIONS
    component_not_available = 1
    operation_no_authorization = 2
    owner_not_exist = 3
    parameter_error = 4
    x_error = 5
    OTHERS = 6.
    IF sy-subrc = 0.
    CLEAR receivers.
    receivers-rcdat = sy-datum.
    receivers-rctim = sy-uzeit.
    receivers-recnam = reclist-rec.
    receivers-recno = folder_list-parno.
    receivers-rectp = folder_list-partp.
    receivers-recyr = folder_list-paryr.
    receivers-sndtp = folder_list-partp.
    receivers-sndyr = folder_list-paryr.
    receivers-sndno = folder_list-parno.
    receivers-sndnam = sy-uname.
    receivers-sndpri = '1'.
    receivers-msgid = 'SO'.
    receivers-msgno = '619'.
    receivers-deliver = 'X'.
    receivers-not_deli = 'X'.
    receivers-read = 'X'.
    receivers-mailstatus = 'E'.
    *receivers-ADR_NAME
    receivers-resend = ' '.
    receivers-sortfield = ' '. "'USER WF_BATCH INDIGO BATCH'.
    receivers-sortclass = '5'.
    APPEND receivers.
    ELSE.
    CLEAR receivers.
    receivers-sel = 'X'.
    receivers-recesc = 'U'.
    receivers-recnam = 'U-'.
    receivers-recextnam = reclist-rec.
    receivers-deliver = 'X'.
    receivers-not_deli = 'X'.
    receivers-read = 'X'.
    receivers-mailstatus = 'E'.
    receivers-adr_name = reclist-rec.
    receivers-sortfield = reclist-rec.
    receivers-sortclass = '5'.
    APPEND receivers.
    ENDIF.
    ENDLOOP.
    ENDFORM.
    FORM snd_email *
    FORM snd_email.
    CALL FUNCTION 'SO_OBJECT_SEND'
    EXPORTING
    folder_id = p_outfolder
    object_id = object_id
    outbox_flag = 'X'
    owner = sy-uname
    check_send_authority = 'X'
    originator_type = 'J'
    link_folder_id = link_folder_id
    TABLES
    objcont = object_content
    receivers = receivers
    EXCEPTIONS
    active_user_not_exist = 1
    communication_failure = 2
    component_not_available = 3
    folder_not_exist = 4
    folder_no_authorization = 5
    forwarder_not_exist = 6
    note_not_exist = 7
    object_not_exist = 8
    object_not_sent = 9
    object_no_authorization = 10
    object_type_not_exist = 11
    operation_no_authorization = 12
    owner_not_exist = 13
    parameter_error = 14
    substitute_not_active = 15
    substitute_not_defined = 16
    system_failure = 17
    too_much_receivers = 18
    user_not_exist = 19
    originator_not_exist = 20
    x_error = 21
    OTHERS = 22.
    IF sy-subrc 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
    WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    ENDIF.
    ENDFORM.
    Thanks
    Nayan

  • Need to send email with excel sheet as attachment: URGENT

    Hi all....i have a requirement where i should extract data from SAP. These datas has to be sent to a mail id entered in the selection screen in excel sheet as an attachment.Can you suggest me any function module that meets the requirement...
    For kind information...there is only one selection field for entering the mail id.
    Thanks in advance
    Nanda

    Hi all....i have a requirement where i should extract data from SAP. These datas has to be sent to a mail id entered in the selection screen in excel sheet as an attachment.Can you suggest me any function module that meets the requirement...
    For kind information...there is only one selection field for entering the mail id.
    Thanks in advance
    Nanda

  • Send Excel sheet as attachment

    Hello,
    One of our user is trying to send one sheet of an excel file as attachment and the user does not want to save the sheet. 
    User is using MS Excel 2010 and Outlook 2013/Office365, the question is " From Excel when you go to File>Save&Send>Send as attachment , you will loose Excel program control until you send the email", user is complaining the she used to
    be able to go back to the original Excel file and continue working even before she send the email before migration her email from Lotus Notes to Outlook.
    Any idea if that will be a setting in Excel need to be enable/disable to let the user send the sheet as attachment and work on the same excel file at the same time even before clicking on send bottom ?
    Thanks,
    Pkakaie

    Hi,
    We just need to educate the user how Outlook works in thie scenario.
    When we use the option Send as Attachment from Excel, we can't edit the Excel from the new message dialog, you may notice Excel is actually "locked". To workaround this, simply create a new message, then drag the Excel
    file to the message window, double click the attached file, thus we can edit it from the new message. Once you finish editing, click Save button and send the file.
    Regards,
    Melon Chen
    TechNet Community Support

  • To send the Payload as PDF Attachment in mail in PI 7.1

    Hi All,
    I have to send a file as PDF attachment using a mail adapter. I gave the Content_Type as 'application.pdf'. I am receiving the mail, but I am unable to open the PDF. It says 'Could not open because the type is not supported or unable to decode'. How do I resolve this?
    Thanks,
    Geetha

    Hi,
    You need to perform the conversion usign the PayloadSwapBean in the  Module tab.
    Please refer to the following link
    /people/sravya.talanki2/blog/2006/11/28/e-mail-xml-messages-in-pdf-format-from-sap-xi
    http://help.sap.com/saphelp_nw04/helpdata/en/2e/bf37423cf7ab04e10000000a1550b0/frameset.htm
    http://help.sap.com/saphelp_nw70ehp1/helpdata/en/cd/5af7c0c994e24fb0d0088443513de2/content.htm
    http://help.sap.com/saphelp_nw70ehp1/helpdata/en/57/0b2c4142aef623e10000000a155106/frameset.htm
    hope this helps,
    Regards,
    Bhanu
    Edited by: nanduri bhanu on May 21, 2009 5:21 AM

  • How to maintain the same layout in excell sheet and in the mailed version

    i have a report which gives the related sap o/p , when we chose a certain layout and trasfer the o/p to excell sheet it maintains the layout but when it comes to the emailed version (i.e., when it is emailed ) , the attachment , it is not maintaining the layout which i have chosen, can u suggest me what i need to do?

    Hello,
    it si not crear where you change the cost of the item to 90 USD?
    If you have a price of 100USD in the sales order then you should have a look in the copy control. Which pricing type is maintained here.
    If you want to take over the price from the sales order to the return order then you should maintain a pricing type which not new determine the VPRS. Then the VPRS should copied from the sales order.
    Please have a look 24832. Here is describe which pricing type is relevant to determine a new condtion.
    I hope that the information are helpful.
    Regards and have a nice day.
    Claudia

  • Send a text Doc as attachment to mail-id through sales order output type

    Hi,
    when i create a SD document and select an output type and external mode before i save the document, it generates a PDF document as an attachment and sents an email. I would like to send a text document as an attachment. Can anybody please tell me the procedure to convert or send the text document as attachment.
    Thanks,
    Ravi

    Hi Ravi sirigiri,
    Donot convert the data into PDF just pass the OTF data to the
    CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
      EXPORTING
        DOCUMENT_DATA              = W_DOC_CHNG
        PUT_IN_OUTBOX              = 'X'
        commit_work                = 'X'
      TABLES
        PACKING_LIST               = I_OBJPACK
       CONTENTS_BIN                = I_OBJBIN
        OBJECT_HEADER              = W_OBJHEAD
        CONTENTS_TXT               = I_OBJTXT
            RECEIVERS                  = I_RECLIST
    Regards,
    Sravanthi

  • How to send other language data into excel file in attachment thru mail

    Hi - ,
    I have to send other language data (russian) into excel file and send as an attachment through e-mail.
    I had used F.M SO_NEW_DOCUMENT_ATT_SEND_API1 to send email.
    In internal table , it is in correct format, but when using SO_NEW_DOCUMENT_ATT_SEND_API1, the excel file sent has junk characters in it.
    Can u please help me on this?
    Thanks,
    Gyanaraj

    Hi ,
    Can anyone help me on this.
    Thanks,
    Gyanaraj

  • Problem in sending the file as an attachment through mail

    Hi,
    I have developed a Zreport. The functionality is like on executing this report it should send an e-mail with an attachment of the data in the xcel format.
    So, while execting this report in background mode in ECC 5.0, it is able to send the mail as an attachment but the file doesn't contain the data in it But, the same report while trying to execute in back ground mode in ECC 6.0, it is able to send the mail with the attachment and the file also has the data.
    So, my question is like are there any patches that has to be installed in ECC 5.0 system to get this successfully done.
    Thanks in advance for your answers.
    Rohith

    Hello,
    Are you using the standad sap function module or using OLE objects to generate excel?
    First try creating the excel file in foreground and see if the data is being populated.
    Kind Regards,
    Niky.

  • Send RFQ as an PDF attachment through mail

    Hi All,
      I wanna send the quotation format to multiple vendors in PDF through mail.
    I have developed RFQ using smartforms.
    Please lemme know how to do this and wat r the steps to be taken.
    Regards,
    Priya

    Hello,
    you only need to convert your smartform into PDF and next send.
    The sending can be seen for example here:
    http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/c2567f2b-0b01-0010-b7b5-977cbf80665d
    or you can just search for the sending code, you will find something like this:
    http://monoceros85.blogspot.com/2009/04/send-email-in-abap-using-class-clbcs.html
    Email using cl_bcs
    Or direct example is here:
    Multiple PDF attachments using CL_BCS Class
    Regards, Otto
    p.s.: please search the next time first and ask later

  • Sending a formatted Excel sheet as an attachment in a mail.

    Hi ,
    I have been using following code to to send formatted excel sheet as attachment in email.
    in the below code I want to change the format of cell from Bold to Underline.
    I have replaced Bold with Underline for below code but it is not working can anyone suggest on this.
    Department
      r_cell = l_document->create_simple_element( name = 'Cell'  parent = r_row ).
      r_cell->set_attribute_ns( name = 'StyleID'  prefix = 'ss'  value = 'Header' ).
      r_data = l_document->create_simple_element( name = 'Data'  value = 'MATNR'  parent = r_cell ).
      r_data->set_attribute_ns( name = 'Type'  prefix = 'ss' value = 'String' ).
      r_format->set_attribute_ns( name = 'Bold'  prefix = 'ss'  value = '1' ).
    Creating a ixml Factory
      l_ixml = cl_ixml=>create( ).
    Creating the DOM Object Model
      l_document = l_ixml->create_document( ).
    Create Root Node 'Workbook'
      l_element_root  = l_document->create_simple_element( name = 'Workbook'  parent = l_document ).  l_element_root->set_attribute( name = 'xmlns'  value = 'urn:schemas-microsoft-com:office:spreadsheet' ).   ns_attribute = l_document->create_namespace_decl( name = 'ss'  prefix = 'xmlns'  uri = 'urn:schemas-microsoft-com:office:spreadsheet' ).  l_element_root->set_attribute_node( ns_attribute ).   ns_attribute = l_document->create_namespace_decl( name = 'x'  prefix = 'xmlns'  uri = 'urn:schemas-microsoft-com:office:excel' ).  l_element_root->set_attribute_node( ns_attribute ).
    Create node for document properties.
      r_element_properties = l_document->create_simple_element( name = 'TEST_REPORT'  parent = l_element_root ).  l_value = sy-uname.  l_document->create_simple_element( name = 'Author'  value = l_value  parent = r_element_properties  ).
    Styles
      r_styles = l_document->create_simple_element( name = 'Styles'  parent = l_element_root  ).
    Style for Header
      r_style  = l_document->create_simple_element( name = 'Style'   parent = r_styles  ).  r_style->set_attribute_ns( name = 'ID'  prefix = 'ss'  value = 'Header' ).   r_format  = l_document->create_simple_element( name = 'Font'  parent = r_style  ).
    Worksheet
      r_worksheet = l_document->create_simple_element( name = 'Worksheet'  parent = l_element_root ).  r_worksheet->set_attribute_ns( name = 'Name'  prefix = 'ss'  value = 'PO Details' ).
    Table
      r_table = l_document->create_simple_element( name = 'Table'  parent = r_worksheet ).  r_table->set_attribute_ns( name = 'FullColumns'  prefix = 'x'  value = '1' ).  r_table->set_attribute_ns( name = 'FullRows'     prefix = 'x'  value = '1' ).
    Column Formatting
      r_column = l_document->create_simple_element( name = 'Column'  parent = r_table ).  r_column->set_attribute_ns( name = 'Width'  prefix = 'ss'  value = '70' ).   r_column = l_document->create_simple_element( name = 'Column'  parent = r_table ).  r_column->set_attribute_ns( name = 'Width'  prefix = 'ss'  value = '70' ).   r_column = l_document->create_simple_element( name = 'Column'  parent = r_table ).  r_column->set_attribute_ns( name = 'Width'  prefix = 'ss'  value = '70' ).   r_column = l_document->create_simple_element( name = 'Column'  parent = r_table ).  r_column->set_attribute_ns( name = 'Width'  prefix = 'ss'  value = '70' ).   r_column = l_document->create_simple_element( name = 'Column'  parent = r_table ).  r_column->set_attribute_ns( name = 'Width'  prefix = 'ss'  value = '70' ).
    Blank Row
      r_row = l_document->create_simple_element( name = 'Row'  parent = r_table ).
    Column Headers Row
      r_row = l_document->create_simple_element( name = 'Row'  parent = r_table ).  r_row->set_attribute_ns( name = 'AutoFitHeight'  prefix = 'ss'  value = '1' ).
    Sr. No.
      r_cell = l_document->create_simple_element( name = 'Cell'  parent = r_row ).  r_cell->set_attribute_ns( name = 'StyleID'  prefix = 'ss'  value = 'Header' ).  r_data = l_document->create_simple_element( name = 'Data'  value = 'EBELN'  parent = r_cell ).  r_data->set_attribute_ns( name = 'Type'  prefix = 'ss' value = 'String' ).
    User Name
      r_cell = l_document->create_simple_element( name = 'Cell'  parent = r_row ).  r_cell->set_attribute_ns( name = 'StyleID'  prefix = 'ss'  value = 'Header' ).  r_data = l_document->create_simple_element( name = 'Data'  value = 'EBELP'  parent = r_cell ).  r_data->set_attribute_ns( name = 'Type'  prefix = 'ss' value = 'String' ).
    Full Name
      r_cell = l_document->create_simple_element( name = 'Cell'  parent = r_row ).  r_cell->set_attribute_ns( name = 'StyleID'  prefix = 'ss'  value = 'Header' ).  r_data = l_document->create_simple_element( name = 'Data'  value = 'AEDAT'  parent = r_cell ).  r_data->set_attribute_ns( name = 'Type'  prefix = 'ss' value = 'String' ).
    Department
      r_cell = l_document->create_simple_element( name = 'Cell'  parent = r_row ).  r_cell->set_attribute_ns( name = 'StyleID'  prefix = 'ss'  value = 'Header' ).  r_data = l_document->create_simple_element( name = 'Data'  value = 'MATNR'  parent = r_cell ).  r_data->set_attribute_ns( name = 'Type'  prefix = 'ss' value = 'String' ).  r_format->set_attribute_ns( name = 'Bold'  prefix = 'ss'  value = '1' ).   r_format  = l_document->create_simple_element( name = 'Interior' parent = r_style  ).  r_format->set_attribute_ns( name = 'Color'   prefix = 'ss'  value = '#C0C0C0' ).  r_format->set_attribute_ns( name = 'Pattern' prefix = 'ss'  value = 'Solid' ).   r_format  = l_document->create_simple_element( name = 'Alignment'  parent = r_style  ).  r_format->set_attribute_ns( name = 'Vertical'  prefix = 'ss'  value = 'Center' ).  r_format->set_attribute_ns( name = 'WrapText'  prefix = 'ss'  value = '1' ).
    Data Table
      LOOP AT it_ekpo INTO wa_ekpo.     r_row = l_document->create_simple_element( name = 'Row'  parent = r_table ).
    Sr. No.
       r_cell = l_document->create_simple_element( name = 'Cell'  parent = r_row ).
       r_cell->set_attribute_ns( name = 'StyleID'  prefix = 'ss'  value = 'Data' ).
       l_value = sy-tabix.
       CONDENSE l_value NO-GAPS.
       r_data = l_document->create_simple_element( name = 'Data'  value = l_value   parent = r_cell ).           " Data
       r_data->set_attribute_ns( name = 'Type'  prefix = 'ss'  value = 'Number' ).                               " Cell format
    EBELN
        r_cell = l_document->create_simple_element( name = 'Cell'  parent = r_row ).    r_cell->set_attribute_ns( name = 'StyleID'  prefix = 'ss'  value = 'Data' ).    l_value = wa_ekpo-ebeln.    r_data = l_document->create_simple_element( name = 'Data'  value = l_value   parent = r_cell ).           " Data    r_data->set_attribute_ns( name = 'Type'  prefix = 'ss'  value = 'String' ).                               " Cell format
    EBELP
        r_cell = l_document->create_simple_element( name = 'Cell'  parent = r_row ).    r_cell->set_attribute_ns( name = 'StyleID'  prefix = 'ss'  value = 'Data' ).    l_value = wa_ekpo-ebelp.    r_data = l_document->create_simple_element( name = 'Data'  value = l_value   parent = r_cell ).           " Data    r_data->set_attribute_ns( name = 'Type'  prefix = 'ss'  value = 'String' ).                               " Cell format
    AEDAT
        r_cell = l_document->create_simple_element( name = 'Cell'  parent = r_row ).    r_cell->set_attribute_ns( name = 'StyleID'  prefix = 'ss'  value = 'Data' ).    l_value = wa_ekpo-aedat.    r_data = l_document->create_simple_element( name = 'Data'  value = l_value   parent = r_cell ).           " Data    r_data->set_attribute_ns( name = 'Type'  prefix = 'ss'  value = 'String' ).                               " Cell format
    MATNR
        r_cell = l_document->create_simple_element( name = 'Cell'  parent = r_row ).    r_cell->set_attribute_ns( name = 'StyleID'  prefix = 'ss'  value = 'Data' ).    l_value = wa_ekpo-matnr.    r_data = l_document->create_simple_element( name = 'Data'  value = l_value   parent = r_cell ).          " Data    r_data->set_attribute_ns( name = 'Type'  prefix = 'ss'  value = 'String' ).                              " Cell format   ENDLOOP.
    Creating a Stream Factory
      l_streamfactory = l_ixml->create_stream_factory( ).
    Connect Internal XML Table to Stream Factory
      l_ostream = l_streamfactory->create_ostream_itable( table = l_xml_table ).
    Rendering the Document
      l_renderer = l_ixml->create_renderer( ostream  = l_ostream  document = l_document ).  l_rc = l_renderer->render( ).
    Saving the XML Document
      l_xml_size = l_ostream->get_num_written_raw( ).
    Before sending the mail,
    LOOP AT l_xml_table INTO wa_xml.
        CLEAR objbin.
        objbin-line = wa_xml-data.
        APPEND objbin to BINARY_CONTENT.
      ENDLOOP.
    Here, objbin is of type SOLIX and BINARY_CONTENT is of type SOLIX_TAB.
    Now, call the method,
    CALL METHOD DOCUMENT->ADD_ATTACHMENT
            EXPORTING  I_ATTACHMENT_TYPE = 'XLS'
                       I_ATTACHMENT_SUBJECT = 'My attachment'
                       I_ATT_CONTENT_HEX    = BINARY_CONTENT   .

    Try this..
      r_format->set_attribute_ns( name = 'Underline'  prefix = 'ss'  value = 'Single' ).

  • Excel sheet as an attachment to the mail box

    Hi,
    i need to send an excel sheet as an attachement to the outlook mail box..
    is any function module is there which serves my requirement? or if any other way is there pls let me know.
    thanks..

    Here is some sample code.
    report zrich_0001.
    parameters: p_email   type somlreci1-receiver
                                   default [email protected]'.
    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.
    Regards,
    Rich Heilman

  • Sending an excel spreadsheet attachment on an E-Mail

    Afternoon,
    Based upon program BCS_EXAMPLE_5 I have created a program that generates an e-mail and creates a spreadsheet attachment. The problem I have is how do get the contents of an internal table into the spreadsheet attachment?
    My attempt at resolving the problem has been as follows:-
    I have declared a variable document which points to the class cl_document_bcs. I have then instantiated the variable using a static method. I then call the method add_attachment (document->add_attachment) and pass the text content which contains two lines of text.
    This creates a spreadsheet will the two lines of text in the first cell.
    Could I use the binary content instead? If so how do I declare a variable that has the same type as a work area of binary content because this has a data type of RAW.
    Any assistance would be very much appreciated. A copy of my code can be seen below:-
    Thanks and regards
    John.
    REPORT bcs_example_5.
    This example shows how to send
      - a simple text provided in an internal table of text lines
      - and an attached MS word document provided in internal table
      - to some internet email address.
    All activities done via facade CL_BCS!
    DATA: send_request       TYPE REF TO cl_bcs.
    DATA: text               TYPE bcsy_text.
    DATA: text_content       TYPE soli_tab.
    DATA: wa_text_content    TYPE soli.
    DATA: binary_content     TYPE solix_tab.
    DATA: wa_binary_content  TYPE solix.
    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: bcs_exception      TYPE REF TO cx_bcs.
    DATA: sent_to_all        TYPE os_boolean.
    Data to be included in the spreadsheet
    DATA:  text2(100) TYPE c VALUE 'ABC'.
    DATA:  int TYPE i VALUE 258.
    DATA:  buffer TYPE xstring.
    DATA:  conv TYPE REF TO cl_abap_conv_out_ce.
    START-OF-SELECTION.
      PERFORM main.
          FORM main                                                     *
    FORM main.
      TRY.
        -------- create persistent send request ------------------------
          send_request = cl_bcs=>create_persistent( ).
        -------- create and set document with attachment ---------------
        create document from internal table with text
          APPEND 'Hello world!' TO text.
          document = cl_document_bcs=>create_document(
                          i_type    = 'RAW'
                          i_text    = text
                          i_length  = '12'
                          i_subject = 'test created by BCS_EXAMPLE_5' ).
        add attachment to document
        BCS expects document content here e.g. from document upload
        binary_content = ...
    *TRY.
         conv = cl_abap_conv_out_ce=>create(
              encoding                      = 'UTF-8'
              endian                        = 'L'
       REPLACEMENT                   = '#'
       IGNORE_CERR                   = ABAP_FALSE
    CATCH CX_PARAMETER_INVALID_RANGE .
    CATCH CX_SY_CODEPAGE_CONVERTER_INIT .
    **ENDTRY.
         CALL METHOD conv->write( data = text n = 4 ).
         CALL METHOD conv->write( data = int ).
         buffer = conv->get_buffer( ).
          wa_text_content = '1234567890ABCDE'.
          APPEND wa_text_content TO text_content.
          wa_text_content = '1234567890ABCDE'.
          APPEND wa_text_content TO text_content.
          wa_binary_content = buffer.
         APPEND wa_binary_content TO binary_content.
         wa_binary_content = '11111111'.
         APPEND wa_binary_content TO binary_content.
          CALL METHOD document->add_attachment
            EXPORTING
              i_attachment_type    = 'XLS'
              i_attachment_subject = 'c:\temp\book2'
              i_att_content_text   = text_content.
             i_att_content_hex    = binary_content
        add document to send request
          CALL METHOD send_request->set_document( document ).
        --------- set sender -------------------------------------------
        note: this is necessary only if you want to set the sender
              different from actual user (SY-UNAME). Otherwise sender is
              set automatically with actual user.
          sender = cl_sapuser_bcs=>create( sy-uname ).
          CALL METHOD send_request->set_sender
            EXPORTING
              i_sender = sender.
        --------- add recipient (e-mail address) -----------------------
        create recipient - please replace e-mail address !!!
          recipient = cl_cam_address_bcs=>create_internet_address(
                                            '[email protected]' ).
        add recipient with its respective attributes to send request
          CALL METHOD send_request->add_recipient
            EXPORTING
              i_recipient = recipient
              i_express   = 'X'.
        ---------- send document ---------------------------------------
    set send immediately flag
          CALL METHOD send_request->set_send_immediately( 'X' ).
          CALL METHOD send_request->send(
            EXPORTING
              i_with_error_screen = 'X'
            RECEIVING
              result              = sent_to_all ).
          IF sent_to_all = 'X'.
            WRITE text-003.
          ENDIF.
          COMMIT WORK.
    *                     exception handling
    * replace this very rudimentary exception handling
    * with your own one !!!
        CATCH cx_bcs INTO bcs_exception.
          WRITE: 'Fehler aufgetreten.'(001).
          WRITE: 'Fehlertyp:'(002), bcs_exception->error_type.
          EXIT.
      ENDTRY.
    ENDFORM.                    "main

    Hi,
    See the Blog..
    /people/thomas.jung3/blog/2004/09/08/sending-e-mail-from-abap--version-610-and-higher--bcs-interface
    Here is the example program to send the EXCEL as a attachment in a email
    http://www.erpgenie.com/sap/abap/code/abap58.htm
    Regards
    Sudheer

Maybe you are looking for

  • How to specify a variable in the script logic

    I want to pass a variable from the process chain using the prompt statement. I  want to refer to the variable name in the script. When I used the following statement in the script file, I got an error when validating the statement below: //Increase W

  • Java HTTP adapter in PI 7.3?

    Hi Experts, Anyone adivse me how to implement the java HTTP to File scenario via PI?especially explain me the HTTP sender side and how to test as well. thanks in advance.

  • IS-U changes of schemas - which table?

    Hi all, Does anybody knows in which table I can find informations about history of changes in schemas ?

  • How to create a new database instance from an existing one?

    Hi, I basically want to create a snapshot of a production instance (version 8.1.7) for querying purposes. Would anyone tell me the steps involved? What I did as follows: 1. Copy all data files to a new location 2. Modify init.ora accordingly. I belie

  • SAP NetWeaver AS ABAP 7.1 for Mobile 7.1 Trial Version

    From where can I get the SAP NetWeaver AS ABAP 7.1 which is required to run data synchronization with NetWeaver Mobile 7.1 ? As per the download notes, for mobile 7.1 - "Note: SAP NetWeaver AS ABAP 7.1 is NOT part of the download package, but is inte