<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: attachment in excel in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/attachment-in-excel/m-p/814137#M42008</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi John,&lt;/P&gt;&lt;P&gt;Thanks for the solution but this is not solving my issue exactly.&lt;/P&gt;&lt;P&gt;My problem is that I am getting data from the database table into an internal table. Now from this internal table, I have to generate an excel file and send this excel file. I have created a new funciton module to do the same and I have inserted hexadecimal '0A' for new line and and '09' for a new cell, but the excel file is not coming in a proper format.&lt;/P&gt;&lt;P&gt;The data is getting scattered in a haphazard manner.&lt;/P&gt;&lt;P&gt;Any poinetr to this problem?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks in advance&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 09 Nov 2004 11:41:04 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2004-11-09T11:41:04Z</dc:date>
    <item>
      <title>attachment in excel</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/attachment-in-excel/m-p/814135#M42006</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I want to send an excel file as an attachment with the mail.&lt;/P&gt;&lt;P&gt;I am usinf SAP standard Function module SO_NEW_DOCUMENT_ATT_SEND_API1.&lt;/P&gt;&lt;P&gt;I am geting an excel file, but it is not coming in a proper format.&lt;/P&gt;&lt;P&gt;I want it in Tab delimited format.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Neelav&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 08 Nov 2004 11:46:27 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/attachment-in-excel/m-p/814135#M42006</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2004-11-08T11:46:27Z</dc:date>
    </item>
    <item>
      <title>Re: attachment in excel</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/attachment-in-excel/m-p/814136#M42007</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Neelav,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Use the following code to upload the excel sheet to SAP:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;      CALL METHOD cl_gui_frontend_services=&amp;gt;gui_upload&lt;/P&gt;&lt;P&gt;        EXPORTING&lt;/P&gt;&lt;P&gt;          filename = zzl_fname&lt;/P&gt;&lt;P&gt;          filetype = 'BIN'&lt;/P&gt;&lt;P&gt;        CHANGING&lt;/P&gt;&lt;P&gt;          data_tab = zt_objcont&lt;/P&gt;&lt;P&gt;         EXCEPTIONS&lt;/P&gt;&lt;P&gt;           OTHERS  = 0.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;and this to calculate the size of the sheet for the packing list:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  zzl_packline-transf_bin = 'X'.&lt;/P&gt;&lt;P&gt;  zzl_packline-head_start = 1.&lt;/P&gt;&lt;P&gt;  zzl_packline-head_num   = 1.&lt;/P&gt;&lt;P&gt;  zzl_packline-body_start = 1.&lt;/P&gt;&lt;P&gt;  zzl_packline-body_num   = &amp;lt;nr of lines in table&amp;gt;.&lt;/P&gt;&lt;P&gt;  zzl_packline-doc_type   = &amp;lt;XLS&amp;gt;.&lt;/P&gt;&lt;P&gt;  zzl_packline-obj_name   = &amp;lt;name&amp;gt;.&lt;/P&gt;&lt;P&gt;  zzl_packline-obj_descr  = &amp;lt;name&amp;gt;.&lt;/P&gt;&lt;P&gt;  zzl_packline-doc_size   = &amp;lt;nr of lines in table&amp;gt; * 255.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;  APPEND zzl_packline&lt;/P&gt;&lt;P&gt;      TO pt_packlist.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;John.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 08 Nov 2004 13:20:54 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/attachment-in-excel/m-p/814136#M42007</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2004-11-08T13:20:54Z</dc:date>
    </item>
    <item>
      <title>Re: attachment in excel</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/attachment-in-excel/m-p/814137#M42008</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi John,&lt;/P&gt;&lt;P&gt;Thanks for the solution but this is not solving my issue exactly.&lt;/P&gt;&lt;P&gt;My problem is that I am getting data from the database table into an internal table. Now from this internal table, I have to generate an excel file and send this excel file. I have created a new funciton module to do the same and I have inserted hexadecimal '0A' for new line and and '09' for a new cell, but the excel file is not coming in a proper format.&lt;/P&gt;&lt;P&gt;The data is getting scattered in a haphazard manner.&lt;/P&gt;&lt;P&gt;Any poinetr to this problem?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks in advance&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 09 Nov 2004 11:41:04 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/attachment-in-excel/m-p/814137#M42008</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2004-11-09T11:41:04Z</dc:date>
    </item>
    <item>
      <title>Re: attachment in excel</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/attachment-in-excel/m-p/814138#M42009</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;try to save you file with ';' as the field separator and save it as file.csv. EXCEL can handle that format.&lt;/P&gt;&lt;P&gt;Hope this helps!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;regards&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Siggi&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 09 Nov 2004 11:54:53 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/attachment-in-excel/m-p/814138#M42009</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2004-11-09T11:54:53Z</dc:date>
    </item>
    <item>
      <title>Re: attachment in excel</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/attachment-in-excel/m-p/814139#M42010</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Neelav,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you want to create a "real" Excel file (and not a CSV-file), you will have to use OLE to create the excel sheet first, which you can then upload into SAP and sent as email attachment.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;John.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 09 Nov 2004 12:11:16 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/attachment-in-excel/m-p/814139#M42010</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2004-11-09T12:11:16Z</dc:date>
    </item>
    <item>
      <title>Re: attachment in excel</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/attachment-in-excel/m-p/814140#M42011</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Neelav,&lt;/P&gt;&lt;P&gt;Found this set of notes regarding sending Excel file attachments. We are doing the same thing and getting similar results, all fields going into one cell.&lt;/P&gt;&lt;P&gt;Did you get to a solution that worked ?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any help gratefully received.&lt;/P&gt;&lt;P&gt;Many thanks&lt;/P&gt;&lt;P&gt;Steve Hammond&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 24 Jan 2005 10:47:04 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/attachment-in-excel/m-p/814140#M42011</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2005-01-24T10:47:04Z</dc:date>
    </item>
    <item>
      <title>Re: attachment in excel</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/attachment-in-excel/m-p/814141#M42012</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;	To take an internal table and convert the data to be used as a attachment in an email, I did the following:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Note that I set sy-batch to allow function module SAP_CONVERT_TO_TXT_FORMAT to work if the program is run in background mode.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Also, concatenate carriage return and line feed to the converted data into objbin. Objbin is passed in as a table on function module SO_DOCUMENT_SEND_API1 for table CONTENTS_BIN.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I hope this helps.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Mike Vondran&lt;/P&gt;&lt;P&gt;eBay&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
form f_convert_data_to_excel.
   data: begin of crlf,
        x(1) type x value '0A',
      end of crlf.
   data: wa_batch like sy-batch.

* Program run in Foreground.
  if sy-batch is initial. 
    sy-batch = 'X'.
    wa_batch = 'X'.
  endif.

* Call table to text function module
  call function 'SAP_CONVERT_TO_TXT_FORMAT'
    exporting
      i_line_header        = 'X'
    tables
      i_tab_sap_data       = i_output_data
    changing
      i_tab_converted_data = wa_data
    exceptions
      conversion_failed    = 1
      others               = 2.
  if sy-subrc &amp;lt;&amp;gt; 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  endif.

* Set back if changed
  if wa_batch = 'X'.
    sy-batch = ' '.
  endif.

* Append formated data and CRLF to objnin
  loop at wa_data into wa_format_data.
    concatenate wa_format_data crlf into objbin-line.
    append objbin.
  endloop.


endform.                    " F_CONVERT_DATA_TO_EXCEL&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 24 Jan 2005 22:47:49 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/attachment-in-excel/m-p/814141#M42012</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2005-01-24T22:47:49Z</dc:date>
    </item>
    <item>
      <title>Re: attachment in excel</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/attachment-in-excel/m-p/814142#M42013</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm sure Neelav came to some resolution long ago, but I had a different solution and thought I might share it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Instead of e-mailing tab-delimited spreadsheets, I e-mail .csv files.  An advantage of this format is that double-clicking in MS Outlook causes Excel to open the attachment directly, without any import conversion prompts.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Problem 1 is converting the internal table to .csv format.  I'd loop at the internal table and use this function module to convert each row:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;FUNCTION z_csv_from_structure.
*"----------------------------------------------------------------------
*"*"Local interface:
*"  IMPORTING
*"     REFERENCE(LR_STRUCT)
*"  EXPORTING
*"     REFERENCE(LW_CSV)
*"----------------------------------------------------------------------

  FIELD-SYMBOLS: &amp;lt;field&amp;gt;.

  DATA: lw_string(1023) TYPE c,
        lw_index LIKE sy-tabix.

* Init.
  CLEAR: lw_csv.

* For each field...
  DO.
    lw_index = sy-index.

*   Capture the first field.
    ASSIGN COMPONENT lw_index OF STRUCTURE lr_struct TO &amp;lt;field&amp;gt;.
    IF sy-subrc &amp;lt;&amp;gt; 0.
      EXIT.
    ENDIF.

*   Convert to text.
    CLEAR: lw_string.
    WRITE &amp;lt;field&amp;gt; TO lw_string LEFT-JUSTIFIED.
    SHIFT lw_string LEFT DELETING LEADING space.

*   Escape any double quotes in the text.
    WHILE lw_string CS '"'.
      REPLACE '"' WITH '(~~&amp;amp;!!@!!&amp;amp;~~)' INTO lw_string.
    ENDWHILE.
    WHILE lw_string CS '(~~&amp;amp;!!@!!&amp;amp;~~)'.
      REPLACE '(~~&amp;amp;!!@!!&amp;amp;~~)' WITH '""' INTO lw_string.
    ENDWHILE.

*   Encapsulate in double quotes if needed.
    IF lw_string CS ',' OR lw_string CS '"'.
      CONCATENATE '"' lw_string '"' INTO lw_string.
    ENDIF.

*   Comma-separate the values.
    IF lw_index = 1.
      lw_csv = lw_string.
    ELSE.
      CONCATENATE lw_csv lw_string INTO lw_csv SEPARATED BY ','.
    ENDIF.

  ENDDO.                             " for each field.

ENDFUNCTION.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I send the e-mail using SAPOffice function module SO_NEW_DOCUMENT_ATT_SEND_API1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;A challenge of using this function module is that the attached spreadsheet must be passed in a table of 256-character rows.  That's rather narrow.  My work-around is to treat the spreadsheet as a character stream, embed my own end-of-line markers in the stream (hex '0D0A' in non-Unicode systems), and chop the stream into 256-character chunks.  In the e-mail API's attachment packing list, I specify document type 'CSV' and set binary transfer mode = 'X'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;(If binary transfer mode is off, SAP appends an EOL to each line of the table you pass it.  Bad.)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here's my code for converting one table of .csv lines into another table of 256-character rows.  Note the .csv lines are already EOL-terminated.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;  CLEAR: lr_attachment, lt_attachment, lw_buffer, lw_buflen, lw_index.
  IF NOT lt_spreadsheet[] IS INITIAL.
    DESCRIBE TABLE lt_spreadsheet LINES lw_tab_lines.
    WHILE lw_index &amp;lt; lw_tab_lines OR lw_buflen &amp;gt; 0.
      WHILE lw_buflen &amp;lt; lw_linlen AND lw_index &amp;lt; lw_tab_lines.
        ADD 1 TO lw_index.
        READ TABLE lt_spreadsheet INTO lr_spreadsheet INDEX lw_index.
        CONCATENATE lw_buffer lr_spreadsheet INTO lw_buffer.
        lw_buflen = strlen( lw_buffer ).
      ENDWHILE.
      CLEAR: lr_attachment.
      lr_attachment-line = lw_buffer.
      APPEND lr_attachment TO lt_attachment.
      SHIFT lw_buffer LEFT BY lw_linlen PLACES.
      lw_buflen = strlen( lw_buffer ).
    ENDWHILE.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For the rest, see the documentation of the e-mail function module.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Eric&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 02 May 2007 16:01:50 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/attachment-in-excel/m-p/814142#M42013</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-05-02T16:01:50Z</dc:date>
    </item>
    <item>
      <title>Re: attachment in excel</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/attachment-in-excel/m-p/814143#M42014</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Try with FM: 'SO_DOCUMENT_REPOSITORY_MANAGER' &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Check the following example program:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.sap-img.com/abap/sending-email-with-attachment.htm" target="test_blank"&gt;http://www.sap-img.com/abap/sending-email-with-attachment.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Bhaskar&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 02 May 2007 16:56:15 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/attachment-in-excel/m-p/814143#M42014</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-05-02T16:56:15Z</dc:date>
    </item>
    <item>
      <title>Re: attachment in excel</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/attachment-in-excel/m-p/814144#M42015</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Concatenate cl_abap_char_utilities&lt;SPAN class="L0S70"&gt;=&amp;gt;cr_lf before every line/record of the file.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="L0S70"&gt;This should resolve the issue.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="L0S70"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="L0S70"&gt;Thanks,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="L0S70"&gt;Anupam&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 23 Apr 2015 21:49:00 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/attachment-in-excel/m-p/814144#M42015</guid>
      <dc:creator>anupam_anand</dc:creator>
      <dc:date>2015-04-23T21:49:00Z</dc:date>
    </item>
  </channel>
</rss>

