<?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: Special characters in e-mail CSV attachment in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/special-characters-in-e-mail-csv-attachment/m-p/730609#M34413</link>
    <description>&lt;P&gt;I think it is MS Excel vs. CSV problem. Not SAP or your program problem. Your CSV should be fine (UTF-8 CSV) using Attempt 2.&lt;/P&gt;
  &lt;P&gt;You can try manually open file in Excel via. CSV file import (it is wizard where you choose what is separator etc.) maybe there is encoding selection?&lt;/P&gt;
  &lt;P&gt;Anyway I just googled this article (and there are some other): &lt;A href="https://donatstudios.com/CSV-An-Encoding-Nightmare" target="test_blank"&gt;https://donatstudios.com/CSV-An-Encoding-Nightmare&lt;/A&gt; which might help and explain problem.&lt;/P&gt;
  &lt;P&gt;&lt;BR /&gt;&lt;/P&gt;
  &lt;P&gt;NOTE: to your manual test creating CSV file:&lt;/P&gt;
  &lt;P&gt;&lt;/P&gt;
  &lt;P&gt;Default codepage when creating Notepad (TXT) file in Windows is suprisingly not UTF-8. You can check it if you select "Save as" in notepad (in popup window on bottom there is a codepage selection).&lt;/P&gt;</description>
    <pubDate>Mon, 03 Sep 2018 14:31:31 GMT</pubDate>
    <dc:creator>Tomas_Buryanek</dc:creator>
    <dc:date>2018-09-03T14:31:31Z</dc:date>
    <item>
      <title>Special characters in e-mail CSV attachment</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/special-characters-in-e-mail-csv-attachment/m-p/730608#M34412</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
  &lt;P&gt;&lt;/P&gt;
  &lt;P&gt;&lt;/P&gt;
  &lt;P&gt;I am trying to attach a content of internal table as CSV file to e-mail. However, I have a problem with special characters (French in this case) when the file is opened by Excel application. If I open it with Notepad everything looks OK so I thought it is a PC issue. However, if I create a CSV file directly from Notepad, then those characters are OK both in Notepad and Excel which indicates that it could be ABAP problem after all. However, I am not sure.&lt;/P&gt;
  &lt;P&gt;Here is what I tried:&lt;/P&gt;
  &lt;P&gt;LV_LINE_STR is a comma-separated string, while line breaks are CL_ABAP_CHAR_UTILITIES=&amp;gt;CL_LF constants.&lt;/P&gt;
  &lt;P&gt;Attempt 1: Straightforward: handling pure text - result is good, except special characters&lt;/P&gt;
  &lt;PRE&gt;&lt;CODE&gt;CALL FUNCTION 'SCMS_STRING_TO_FTEXT'
    EXPORTING
      text      = lv_line_str
    IMPORTING
      length    = lv_length
    TABLES
      ftext_tab = lt_att_content_text.

  lo_document-&amp;gt;add_attachment(
        i_attachment_type     = CONV #( 'CSV'  )
        i_attachment_subject  = CONV #( p_attnam )
        i_attachment_size     = CONV #( lv_length ) 
        i_att_content_text    = lt_att_content_text
  ).

&lt;/CODE&gt;&lt;/PRE&gt;
  &lt;P&gt;Attempt 2: Maybe UTF-8 conversion (must go through binary) would help? The result was exactly the same as above&lt;/P&gt;
  &lt;PRE&gt;&lt;CODE&gt;DATA:
    lt_att_content_text_bin TYPE solix_tab.
  DATA(lv_line_str_conv) = cl_abap_codepage=&amp;gt;convert_to(
      source                        = lv_line_str
      codepage                      = 'DEFAULT' "'UTF-8'
  ).

  CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
    EXPORTING
      buffer                = lv_line_str_conv
   IMPORTING
     OUTPUT_LENGTH         = lv_length
    tables
      binary_tab            = lt_att_content_text_bin .

  lo_document-&amp;gt;add_attachment(
        i_attachment_type     = CONV #( 'CSV'  )
        i_attachment_subject  = CONV #( 'Item list' )
        i_attachment_size     = CONV #( lv_length ) 
        i_att_content_hex     = lt_att_content_text_bin
  ).

&lt;/CODE&gt;&lt;/PRE&gt;
  &lt;P&gt;Thanks in advance for your help!&lt;/P&gt;
  &lt;P&gt;KR,&lt;/P&gt;
  &lt;P&gt;Igor&lt;/P&gt;
  &lt;P&gt;&lt;/P&gt;
  &lt;P&gt;&lt;/P&gt;
  &lt;P&gt;&lt;/P&gt;
  &lt;P&gt;&lt;/P&gt;
  &lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 03 Sep 2018 12:58:13 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/special-characters-in-e-mail-csv-attachment/m-p/730608#M34412</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2018-09-03T12:58:13Z</dc:date>
    </item>
    <item>
      <title>Re: Special characters in e-mail CSV attachment</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/special-characters-in-e-mail-csv-attachment/m-p/730609#M34413</link>
      <description>&lt;P&gt;I think it is MS Excel vs. CSV problem. Not SAP or your program problem. Your CSV should be fine (UTF-8 CSV) using Attempt 2.&lt;/P&gt;
  &lt;P&gt;You can try manually open file in Excel via. CSV file import (it is wizard where you choose what is separator etc.) maybe there is encoding selection?&lt;/P&gt;
  &lt;P&gt;Anyway I just googled this article (and there are some other): &lt;A href="https://donatstudios.com/CSV-An-Encoding-Nightmare" target="test_blank"&gt;https://donatstudios.com/CSV-An-Encoding-Nightmare&lt;/A&gt; which might help and explain problem.&lt;/P&gt;
  &lt;P&gt;&lt;BR /&gt;&lt;/P&gt;
  &lt;P&gt;NOTE: to your manual test creating CSV file:&lt;/P&gt;
  &lt;P&gt;&lt;/P&gt;
  &lt;P&gt;Default codepage when creating Notepad (TXT) file in Windows is suprisingly not UTF-8. You can check it if you select "Save as" in notepad (in popup window on bottom there is a codepage selection).&lt;/P&gt;</description>
      <pubDate>Mon, 03 Sep 2018 14:31:31 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/special-characters-in-e-mail-csv-attachment/m-p/730609#M34413</guid>
      <dc:creator>Tomas_Buryanek</dc:creator>
      <dc:date>2018-09-03T14:31:31Z</dc:date>
    </item>
    <item>
      <title>Re: Special characters in e-mail CSV attachment</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/special-characters-in-e-mail-csv-attachment/m-p/730610#M34414</link>
      <description>&lt;P&gt;HI&lt;/P&gt;
  &lt;P&gt;please check SAP example report bcs_example_7 and convert the text string into utf-16e, as it is don in this report.&lt;/P&gt;
  &lt;P&gt;Best regards&lt;/P&gt;
  &lt;P&gt;Jozsef H&lt;/P&gt;
  &lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 03 Sep 2018 14:46:46 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/special-characters-in-e-mail-csv-attachment/m-p/730610#M34414</guid>
      <dc:creator>jozsef_hegyi</dc:creator>
      <dc:date>2018-09-03T14:46:46Z</dc:date>
    </item>
    <item>
      <title>Re: Special characters in e-mail CSV attachment</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/special-characters-in-e-mail-csv-attachment/m-p/730611#M34415</link>
      <description>&lt;P&gt;What is the french character involved ? &lt;BR /&gt;&lt;BR /&gt;Why don't you provide a simple test program so everybody can do a try ?&lt;/P&gt;
  &lt;BR /&gt;</description>
      <pubDate>Mon, 03 Sep 2018 15:45:52 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/special-characters-in-e-mail-csv-attachment/m-p/730611#M34415</guid>
      <dc:creator>chaouki_akir</dc:creator>
      <dc:date>2018-09-03T15:45:52Z</dc:date>
    </item>
    <item>
      <title>Re: Special characters in e-mail CSV attachment</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/special-characters-in-e-mail-csv-attachment/m-p/730612#M34416</link>
      <description>&lt;P&gt;Hi, Jozsef,&lt;/P&gt;
  &lt;P&gt;Thanks for this hint! The fantastic class CL_BCS_CONVERT for content conversion (RAW, TXT, STRING, XSTRING, SOLI, SOLIX, BIN, OTF, XTAB, TAB) has so many good methods. In my case it magically solved the problem and reduced number of calls and custom code size. &lt;/P&gt;
  &lt;P&gt;Cheers!&lt;/P&gt;
  &lt;P&gt;Igor&lt;/P&gt;
  &lt;P&gt;&lt;STRONG&gt;&lt;/STRONG&gt;&lt;U&gt;&lt;/U&gt;&lt;SUB&gt;&lt;/SUB&gt;&lt;SUP&gt;&lt;/SUP&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 04 Sep 2018 07:02:56 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/special-characters-in-e-mail-csv-attachment/m-p/730612#M34416</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2018-09-04T07:02:56Z</dc:date>
    </item>
    <item>
      <title>Re: Special characters in e-mail CSV attachment</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/special-characters-in-e-mail-csv-attachment/m-p/730613#M34417</link>
      <description>&lt;P&gt;Hi, Tomas,&lt;/P&gt;
  &lt;P&gt;Thanks for your effort! Now I learned something useful about Notepad &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
  &lt;P&gt;You were right: manually created CSV via notepad creates it in 'ANSI' codepage, unavailable (or differently named in table TCP00A) in SAP. But luckily the class CL_BCS_CONVERT magically solves it all.&lt;/P&gt;</description>
      <pubDate>Tue, 04 Sep 2018 07:16:45 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/special-characters-in-e-mail-csv-attachment/m-p/730613#M34417</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2018-09-04T07:16:45Z</dc:date>
    </item>
  </channel>
</rss>

