<?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: Wrong Encoding for TXT-Attachement with BCS Class in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/wrong-encoding-for-txt-attachement-with-bcs-class/m-p/788405#M39801</link>
    <description>&lt;P&gt;When you do the encoding with code page 1100 for ISO-8859-1 (API by order of preference based on your release: CL_ABAP_CONV_CODEPAGE (&amp;gt;=7.53), CL_ABAP_CODEPAGE (&amp;gt;=7.02), CL_ABAP_CONV_OUT_CE), you convert your text into bytes, then you send the bytes via the parameter I_ATT_CONTENT_HEX.&lt;/P&gt;</description>
    <pubDate>Wed, 06 Mar 2019 11:03:00 GMT</pubDate>
    <dc:creator>Sandra_Rossi</dc:creator>
    <dc:date>2019-03-06T11:03:00Z</dc:date>
    <item>
      <title>Wrong Encoding for TXT-Attachement with BCS Class</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/wrong-encoding-for-txt-attachement-with-bcs-class/m-p/788404#M39800</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
  &lt;P&gt;I'm trying to send a TXT-File via mail.&lt;BR /&gt;I have an internal table with different fields (not only strings).&lt;BR /&gt;The TXT file in the attachement has the Codepage 4110 UTF-8 but I need it to be 1100 iso-8859-1.&lt;/P&gt;
  &lt;P&gt;I have tried a lot of different conversions but nothing seems to work.&lt;BR /&gt;My coding looks as follows:&lt;/P&gt; 
  &lt;PRE&gt;&lt;CODE&gt;      LOOP AT itab INTO s_itab.
        DO.
          UNASSIGN &amp;lt;fs&amp;gt;.
          ASSIGN COMPONENT sy-index OF STRUCTURE s_itab TO &amp;lt;fs&amp;gt;.
          IF &amp;lt;fs&amp;gt; IS ASSIGNED.
            CONCATENATE lv_string &amp;lt;fs&amp;gt; INTO lv_string.
          ELSE.
            EXIT.
          ENDIF.
        ENDDO.
        CONCATENATE lv_data_string lv_string cl_abap_char_utilities=&amp;gt;cr_lf INTO lv_data_string.
        CLEAR: s_itab, lv_string.
      ENDLOOP.
 #############################

    gv_soli = cl_bcs_convert=&amp;gt;string_to_soli( iv_string = lv_data_string ).


      CALL METHOD gr_document-&amp;gt;add_attachment
        EXPORTING
          i_attachment_type     = 'TXT'  
          i_attachment_subject  = 'Test'
*         i_attachment_size     =     
*          i_attachment_language =     " 
          i_att_content_text    = gv_soli   "
*         i_att_content_hex     =   )
*         i_attachment_header   = 
*         iv_vsi_profile        =     " Viren-Scan-Profil
        .

&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 06 Mar 2019 09:29:52 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/wrong-encoding-for-txt-attachement-with-bcs-class/m-p/788404#M39800</guid>
      <dc:creator>former_member571793</dc:creator>
      <dc:date>2019-03-06T09:29:52Z</dc:date>
    </item>
    <item>
      <title>Re: Wrong Encoding for TXT-Attachement with BCS Class</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/wrong-encoding-for-txt-attachement-with-bcs-class/m-p/788405#M39801</link>
      <description>&lt;P&gt;When you do the encoding with code page 1100 for ISO-8859-1 (API by order of preference based on your release: CL_ABAP_CONV_CODEPAGE (&amp;gt;=7.53), CL_ABAP_CODEPAGE (&amp;gt;=7.02), CL_ABAP_CONV_OUT_CE), you convert your text into bytes, then you send the bytes via the parameter I_ATT_CONTENT_HEX.&lt;/P&gt;</description>
      <pubDate>Wed, 06 Mar 2019 11:03:00 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/wrong-encoding-for-txt-attachement-with-bcs-class/m-p/788405#M39801</guid>
      <dc:creator>Sandra_Rossi</dc:creator>
      <dc:date>2019-03-06T11:03:00Z</dc:date>
    </item>
    <item>
      <title>Re: Wrong Encoding for TXT-Attachement with BCS Class</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/wrong-encoding-for-txt-attachement-with-bcs-class/m-p/788406#M39802</link>
      <description>&lt;P&gt;EDIT: Maybe I could add more:&lt;BR /&gt;I need it to be ANSI since UTF-8 without BOM can't be read correctly by my other software.&lt;/P&gt;&lt;P&gt;--&lt;/P&gt;&lt;P&gt;Thank you for your answer. I'm trying to figure out sending mails via SAP on my own, as well as the codepage stuff.&lt;BR /&gt;So please excuse me if I'm missing obvious parts.&lt;BR /&gt;&lt;BR /&gt;I tried to implement it. I have to convert the string to a solix tab right after, correct?&lt;BR /&gt;Well my TXT Attachement now only contains bytes as you've said.&lt;/P&gt;&lt;P&gt;Is there a way to display them as before? Or does the codepage 1100 always display them as Bytes? How could a program like word read it?&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;cl_abap_codepage=&amp;gt;convert_to(
  EXPORTING
    source                        = lv_data_string    " source string
    codepage                      = `ISO-8859-1`    " codepage name
*    endian                        =     " Nicht benutzen (da wirkungslos!)
*    replacement                   = '#'    " Ersatzzeichen für Zeichensatzkonvertierung
*    ignore_cerr                   = ABAP_FALSE    " Ignoriere Konvertierungsfehler
  RECEIVING
    result                        = lv_data_string2
).

cl_bcs_convert=&amp;gt;string_to_solix(
  EXPORTING
    iv_string   =  lv_Data_string2   " Eingabedaten
*    iv_codepage =     " Zielcodepage in SAP Form  (Default = SAPconnect Einstellung)
*    iv_add_bom  =     " Byte-Order-Mark hinzufügen
  IMPORTING
    et_solix    =  gv_solix   " Ausgabedaten
*    ev_size     =     " Größe des Dokumentinhalts
).
&amp;lt;br&amp;gt;      CALL METHOD gr_document-&amp;gt;add_attachment
        EXPORTING
          i_attachment_type     = 'TXT'  " oder XLS
          i_attachment_subject  = 'Test'
         i_att_content_hex     = gv_solix    " Inhalt (binär)

        .
&amp;lt;br&amp;gt;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 06 Mar 2019 11:24:00 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/wrong-encoding-for-txt-attachement-with-bcs-class/m-p/788406#M39802</guid>
      <dc:creator>former_member571793</dc:creator>
      <dc:date>2019-03-06T11:24:00Z</dc:date>
    </item>
    <item>
      <title>Re: Wrong Encoding for TXT-Attachement with BCS Class</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/wrong-encoding-for-txt-attachement-with-bcs-class/m-p/788407#M39803</link>
      <description>&lt;A href="https://answers.sap.com/users/306263/tmeiners.html"&gt;Thimo Meiners&lt;/A&gt; your code is correct. Of course the software which displays the attachment has to recognize it's ISO-8859-1, but nothing says it in the file. With the Unicode BOM (UTF), softwares should be able to recognize automatically, if they are written well. If I open it with MS Word, there's a dialog to confirm the code page or select another one.When you say "codepage displays as bytes", I don't understand what you mean.</description>
      <pubDate>Wed, 06 Mar 2019 12:26:44 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/wrong-encoding-for-txt-attachement-with-bcs-class/m-p/788407#M39803</guid>
      <dc:creator>Sandra_Rossi</dc:creator>
      <dc:date>2019-03-06T12:26:44Z</dc:date>
    </item>
    <item>
      <title>Re: Wrong Encoding for TXT-Attachement with BCS Class</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/wrong-encoding-for-txt-attachement-with-bcs-class/m-p/788408#M39804</link>
      <description>&lt;P&gt;I'll provide an example:&lt;/P&gt;&lt;P&gt;I have both variables in the coding above.&lt;/P&gt;&lt;P&gt;Lv_data_string is = Dö;John;F;5648132;2000;J.DOE@DOE.COM;28.09.1983;;;;;;;\r\n&lt;/P&gt;&lt;P&gt;The txt file would contain above text but with the wrong encoding.&lt;/P&gt;&lt;P&gt;If I use the convert from above&lt;BR /&gt;Lv_data_string2 is = 406B25FC7A3B416C65763B463B31303038333438303B3524303054B412E414B5955455A40524F5A49414C413D545E4554253454E2E44453B32382E30392E313939333B3B3B3B3B3B3B0D0A&lt;/P&gt;&lt;P&gt;And the txt file contains that which is unreadable.&lt;/P&gt;</description>
      <pubDate>Wed, 06 Mar 2019 12:40:59 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/wrong-encoding-for-txt-attachement-with-bcs-class/m-p/788408#M39804</guid>
      <dc:creator>former_member571793</dc:creator>
      <dc:date>2019-03-06T12:40:59Z</dc:date>
    </item>
    <item>
      <title>Re: Wrong Encoding for TXT-Attachement with BCS Class</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/wrong-encoding-for-txt-attachement-with-bcs-class/m-p/788409#M39805</link>
      <description>&lt;P&gt;&lt;A href="https://answers.sap.com/users/306263/tmeiners.html"&gt;Thimo Meiners&lt;/A&gt; wow the hex code is &lt;STRONG&gt;not&lt;/STRONG&gt; ISO-8859-1 at all. I just realized, did you define lv_data_string2 as XSTRING? You should also use &lt;STRONG&gt;XSTRING&lt;/STRONG&gt;_TO_SOLIX.&lt;/P&gt;</description>
      <pubDate>Wed, 06 Mar 2019 12:47:42 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/wrong-encoding-for-txt-attachement-with-bcs-class/m-p/788409#M39805</guid>
      <dc:creator>Sandra_Rossi</dc:creator>
      <dc:date>2019-03-06T12:47:42Z</dc:date>
    </item>
    <item>
      <title>Re: Wrong Encoding for TXT-Attachement with BCS Class</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/wrong-encoding-for-txt-attachement-with-bcs-class/m-p/788410#M39806</link>
      <description>&lt;P&gt;Thank you Sandra Rossi, it worked &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I defined lv_data_string2 as XSTRING and used xstring_to_solix.&lt;BR /&gt;Do you have a short explanation as for why I needed to use Xstring?&lt;BR /&gt;I thought using string_to_solix would work just as fine.&lt;/P&gt;</description>
      <pubDate>Wed, 06 Mar 2019 13:32:04 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/wrong-encoding-for-txt-attachement-with-bcs-class/m-p/788410#M39806</guid>
      <dc:creator>former_member571793</dc:creator>
      <dc:date>2019-03-06T13:32:04Z</dc:date>
    </item>
    <item>
      <title>Re: Wrong Encoding for TXT-Attachement with BCS Class</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/wrong-encoding-for-txt-attachement-with-bcs-class/m-p/788411#M39807</link>
      <description>&lt;P&gt;&lt;A href="https://answers.sap.com/users/306263/tmeiners.html"&gt;Thimo Meiners&lt;/A&gt; First I don't have any idea why string gave you this weird result. Now cl_abap_codepage=&amp;gt;convert_to returns a XSTRING, so use a XSTRING. Instead, if you store the result in a string, the string will be the XSTRING converted into the hexadecimal textual representation of the xstring, which is completely different.&lt;/P&gt;</description>
      <pubDate>Wed, 06 Mar 2019 15:52:02 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/wrong-encoding-for-txt-attachement-with-bcs-class/m-p/788411#M39807</guid>
      <dc:creator>Sandra_Rossi</dc:creator>
      <dc:date>2019-03-06T15:52:02Z</dc:date>
    </item>
  </channel>
</rss>

