<?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: ABAP character encoding conversion in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/abap-character-encoding-conversion/m-p/12046397#M1968360</link>
    <description>&lt;P&gt;Thank you Sandra.&lt;/P&gt;&lt;P&gt;So I guess my file is correctly created (despite the line breaks are not correctly interpreted).&lt;/P&gt;</description>
    <pubDate>Wed, 04 Sep 2019 12:46:01 GMT</pubDate>
    <dc:creator>marco-silva</dc:creator>
    <dc:date>2019-09-04T12:46:01Z</dc:date>
    <item>
      <title>ABAP character encoding conversion</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/abap-character-encoding-conversion/m-p/12046393#M1968356</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
  &lt;P&gt;I'm trying to export a data file in encoding ISO-8859-15. This code type allows characters like €, Š, š, Ž, ž, Œ, œ or Ÿ.&lt;/P&gt;
  &lt;P&gt;I've looked into the ABAP tools available for this purpose, especially thru this great &lt;A href="https://wiki.scn.sap.com/wiki/display/ABAP/Character+encoding+conversion"&gt;blog&lt;/A&gt; from &lt;SPAN class="mention-scrubbed"&gt;sandra.rossi&lt;/SPAN&gt;.&lt;/P&gt;
  &lt;P&gt;Here you can find my testing code:&lt;/P&gt; 
  &lt;PRE&gt;&lt;CODE&gt;*&amp;amp;---------------------------------------------------------------------*
*&amp;amp; Report ZBC_FILE_ENCODING
*&amp;amp;---------------------------------------------------------------------*
*&amp;amp; Encoding test report
*&amp;amp;---------------------------------------------------------------------*

REPORT zbc_file_encoding.

DATA: gv_file              TYPE text255,
      gt_file              LIKE STANDARD TABLE OF gv_file,
      gv_filename          TYPE string,
      gv_path              TYPE string,
      gv_fullpath          TYPE string,
      gv_bin_filesize      TYPE i,
      gt_bin_data          TYPE solix_tab,
      gv_xfile             TYPE xstring,
      gv_sfile             TYPE string,
      gv_sap_codepage      TYPE cpcodepage,
      gv_default_file_name TYPE string,
      gv_external_name     TYPE tcp00a-cpattr,
      go_abap_conv_obj     TYPE REF TO cl_abap_conv_obj,
      gv_incode            TYPE cpcodepage,
      gv_outcode           TYPE cpcodepage.

gv_file = 'A;B;C;é;€;Š;š;Ž;ž;Œ;œ;Ÿ'.
APPEND gv_file TO gt_file.
gv_file = 'D;E;F;é;€;Š;š;Ž;ž;Œ;œ;Ÿ'.
APPEND gv_file TO gt_file.

LOOP AT gt_file INTO gv_file.
  CONCATENATE gv_sfile gv_file cl_abap_char_utilities=&amp;gt;cr_lf INTO gv_sfile.
ENDLOOP.

gv_external_name = 'ISO-8859-15'.

CALL FUNCTION 'SCP_CODEPAGE_BY_EXTERNAL_NAME'
  EXPORTING
    external_name = gv_external_name
  IMPORTING
    sap_codepage  = gv_sap_codepage
  EXCEPTIONS
    OTHERS        = 1.

IF sy-subrc NE 0.
  MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.

CALL FUNCTION 'SCP_GET_CODEPAGE_NUMBER'
  EXPORTING
    database_also = ' '
  IMPORTING
    appl_codepage = gv_incode
  EXCEPTIONS
    OTHERS        = 1.

IF sy-subrc NE 0.
  MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.

gv_outcode = gv_sap_codepage.

CREATE OBJECT go_abap_conv_obj
  EXPORTING
    incode   = gv_incode
    outcode  = gv_outcode
    miss     = 'S'
    ctrlcode = '.'
  EXCEPTIONS
    OTHERS   = 1.

IF sy-subrc NE 0.
  MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.

CALL METHOD go_abap_conv_obj-&amp;gt;convert
  EXPORTING
    inbuff    = gv_sfile
    outbufflg = gv_bin_filesize
  IMPORTING
    outbuff   = gv_xfile
  EXCEPTIONS
    OTHERS    = 1.

IF sy-subrc NE 0.
  MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.

CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
  EXPORTING
    buffer        = gv_xfile
  IMPORTING
    output_length = gv_bin_filesize
  TABLES
    binary_tab    = gt_bin_data.

CONCATENATE 'test_encoding_' gv_external_name '.csv' INTO gv_default_file_name.

CALL METHOD cl_gui_frontend_services=&amp;gt;file_save_dialog
  EXPORTING
    default_file_name = gv_default_file_name
  CHANGING
    filename          = gv_filename
    path              = gv_path
    fullpath          = gv_fullpath
  EXCEPTIONS
    OTHERS            = 1.

IF sy-subrc NE 0.
  MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.

CALL METHOD cl_gui_frontend_services=&amp;gt;gui_download
  EXPORTING
    bin_filesize         = gv_bin_filesize
    filename             = gv_fullpath
    filetype             = 'BIN'
    show_transfer_status = ' '
  CHANGING
    data_tab             = gt_bin_data
  EXCEPTIONS
    OTHERS               = 1.

IF sy-subrc NE 0.
  MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.&lt;/CODE&gt;&lt;/PRE&gt;
  &lt;P&gt;Unfortunately, at the end, I don't get what I'm expecting: &lt;/P&gt;
  &lt;P&gt;&lt;IMG class="migrated-image" src="https://community.sap.com/legacyfs/online/storage/attachments/storage/7/attachments/1724246-result.png" /&gt;&lt;/P&gt;
  &lt;P&gt;Notepad++ says that the format is Windows-1252, the special characters are messed up and even the carriage return and line feed are not recognized. &lt;/P&gt;
  &lt;P&gt;Any idea of what I'm doing wrong and how to achieve my goal? &lt;/P&gt;
  &lt;P&gt;Thanks in advance for your help. &lt;/P&gt;
  &lt;P&gt;Best regards, &lt;/P&gt;
  &lt;P&gt;Marco Silva&lt;/P&gt;</description>
      <pubDate>Wed, 04 Sep 2019 09:22:26 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/abap-character-encoding-conversion/m-p/12046393#M1968356</guid>
      <dc:creator>marco-silva</dc:creator>
      <dc:date>2019-09-04T09:22:26Z</dc:date>
    </item>
    <item>
      <title>Re: ABAP character encoding conversion</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/abap-character-encoding-conversion/m-p/12046394#M1968357</link>
      <description>&lt;P&gt;Hi Marco,&lt;/P&gt;&lt;P&gt;does it &lt;EM&gt;have&lt;/EM&gt; to be ISO-8859-15 or is this provicient as well?&lt;/P&gt;&lt;P&gt;&lt;IMG class="migrated-image" src="https://community.sap.com/legacyfs/online/storage/attachments/storage/7/attachments/1726101-capture.png" /&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 04 Sep 2019 12:29:40 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/abap-character-encoding-conversion/m-p/12046394#M1968357</guid>
      <dc:creator>former_member259807</dc:creator>
      <dc:date>2019-09-04T12:29:40Z</dc:date>
    </item>
    <item>
      <title>Re: ABAP character encoding conversion</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/abap-character-encoding-conversion/m-p/12046395#M1968358</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I have to produce a file that legally should be in the ISO-8859-15 encoding. But I guess the main point is to allow the Euro symbol (€).&lt;/P&gt;&lt;P&gt;Anyway, since I can find the ISO-8859-15 attribute in table TCP00A of SAP for page code 1164, shouldn't be the system capable of creating the file in the right encoding?&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;P&gt;Marco&lt;/P&gt;</description>
      <pubDate>Wed, 04 Sep 2019 12:38:16 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/abap-character-encoding-conversion/m-p/12046395#M1968358</guid>
      <dc:creator>marco-silva</dc:creator>
      <dc:date>2019-09-04T12:38:16Z</dc:date>
    </item>
    <item>
      <title>Re: ABAP character encoding conversion</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/abap-character-encoding-conversion/m-p/12046396#M1968359</link>
      <description>&lt;P&gt;It's just a Notepad++ question. It cannot guess efficiently what the actual code page is (the information is not stored) so there's a very simple algorithm to sniff the first bytes and guess with a high risk of false positives.&lt;/P&gt;&lt;P&gt;Manually force Notepad++ to consider it's ISO-8859-15 via the menu, and it will display the characters corresponding to the ISO-8859-15 character set:&lt;/P&gt;&lt;P&gt;&lt;IMG class="migrated-image" src="https://community.sap.com/legacyfs/online/storage/attachments/storage/7/attachments/1723082-2019-09-04-test-encoding-iso-8859-15-notepad.png" /&gt;&lt;/P&gt;&lt;P&gt;PS: thanks for the minimal reproducible example! (no time lost by people who try to answer)&lt;/P&gt;</description>
      <pubDate>Wed, 04 Sep 2019 12:38:56 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/abap-character-encoding-conversion/m-p/12046396#M1968359</guid>
      <dc:creator>Sandra_Rossi</dc:creator>
      <dc:date>2019-09-04T12:38:56Z</dc:date>
    </item>
    <item>
      <title>Re: ABAP character encoding conversion</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/abap-character-encoding-conversion/m-p/12046397#M1968360</link>
      <description>&lt;P&gt;Thank you Sandra.&lt;/P&gt;&lt;P&gt;So I guess my file is correctly created (despite the line breaks are not correctly interpreted).&lt;/P&gt;</description>
      <pubDate>Wed, 04 Sep 2019 12:46:01 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/abap-character-encoding-conversion/m-p/12046397#M1968360</guid>
      <dc:creator>marco-silva</dc:creator>
      <dc:date>2019-09-04T12:46:01Z</dc:date>
    </item>
    <item>
      <title>Re: ABAP character encoding conversion</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/abap-character-encoding-conversion/m-p/12046398#M1968361</link>
      <description>&lt;P&gt;&lt;IMG class="migrated-image" src="https://community.sap.com/legacyfs/online/storage/attachments/storage/7/attachments/1726102-capture2.png" /&gt;&lt;/P&gt;&lt;P&gt;I guess you will still have the issue of the file itself using the correct encoding, but in N++ at least you can see a correct representation using the encoding.&lt;/P&gt;&lt;P&gt;Update:&lt;/P&gt;&lt;P&gt;this is done by not adding the CRLF to the table lines. No conversion of the table lines. so just supply the table (gt_file) and do the gui_download using codepage 1164.&lt;/P&gt;</description>
      <pubDate>Wed, 04 Sep 2019 12:54:40 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/abap-character-encoding-conversion/m-p/12046398#M1968361</guid>
      <dc:creator>former_member259807</dc:creator>
      <dc:date>2019-09-04T12:54:40Z</dc:date>
    </item>
    <item>
      <title>Re: ABAP character encoding conversion</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/abap-character-encoding-conversion/m-p/12046399#M1968362</link>
      <description>&lt;P&gt;Hmm # seems not good. It is # and not CR nor LF. Because of MISS='S' and CTRLCODE='.'? (substitute control characters by SUBSTC which is # by default). Ue CTRLCODE='T' (try)&lt;/P&gt;&lt;P&gt;Anyway, why not using the recommended class CL_ABAP_CODEPAGE?&lt;/P&gt;</description>
      <pubDate>Wed, 04 Sep 2019 12:59:22 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/abap-character-encoding-conversion/m-p/12046399#M1968362</guid>
      <dc:creator>Sandra_Rossi</dc:creator>
      <dc:date>2019-09-04T12:59:22Z</dc:date>
    </item>
    <item>
      <title>Re: ABAP character encoding conversion</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/abap-character-encoding-conversion/m-p/12046400#M1968363</link>
      <description>&lt;P&gt;You're right. I started with class CL_ABAP_CODEPAGE, but since I thought I wasn't getting the expected result, I tried others and ended up with CL_ABAP_CONV_OBJ. But I'll get back to CL_ABAP_CODEPAGE, it seems to perform correctly the task.&lt;/P&gt;&lt;P&gt;Thanks a lot for your help!&lt;/P&gt;</description>
      <pubDate>Wed, 04 Sep 2019 13:23:04 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/abap-character-encoding-conversion/m-p/12046400#M1968363</guid>
      <dc:creator>marco-silva</dc:creator>
      <dc:date>2019-09-04T13:23:04Z</dc:date>
    </item>
    <item>
      <title>Re: ABAP character encoding conversion</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/abap-character-encoding-conversion/m-p/12046401#M1968364</link>
      <description>&lt;P&gt;AFAIK, notepad++ use uchardet project to identify code page. Check at &lt;A href="https://gitlab.freedesktop.org/uchardet/"&gt;https://gitlab.freedesktop.org/uchardet/&lt;/A&gt; if you want to raise an issue &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 04 Sep 2019 13:46:47 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/abap-character-encoding-conversion/m-p/12046401#M1968364</guid>
      <dc:creator>RaymondGiuseppi</dc:creator>
      <dc:date>2019-09-04T13:46:47Z</dc:date>
    </item>
    <item>
      <title>Re: ABAP character encoding conversion</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/abap-character-encoding-conversion/m-p/12046402#M1968365</link>
      <description>&lt;P&gt;&lt;A href="https://answers.sap.com/users/1270/raymondgiuseppi.html"&gt;Raymond Giuseppi&lt;/A&gt; I guess that the only way to identify the code page/character set is to count the number occurrences of each character and compare to a model of statistical character counts per language/character set, so with the given characters it can't work, but with this text in Estonian that should work (I hope): Caron, tuntud ka kui hachek, kiil, tšekk, ümberpööratud ümbermõõt, ümberpööratud müts, on diakriitik.&lt;/P&gt;&lt;P&gt;UPDATE: hmmm, no, it doesn't work. Maybe statistics are not available for Estonian...&lt;/P&gt;</description>
      <pubDate>Wed, 04 Sep 2019 14:38:21 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/abap-character-encoding-conversion/m-p/12046402#M1968365</guid>
      <dc:creator>Sandra_Rossi</dc:creator>
      <dc:date>2019-09-04T14:38:21Z</dc:date>
    </item>
    <item>
      <title>Re: ABAP character encoding conversion</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/abap-character-encoding-conversion/m-p/12046403#M1968366</link>
      <description>&lt;P&gt;&lt;A href="https://answers.sap.com/users/208208/marcosilvaapplium.html"&gt;Marco SILVA&lt;/A&gt; by the way, why ISO-8859-15, and not UTF-8 (= the first 3 bytes of the file can contain a BOM which identifies that it's a UTF-8 file; it's much more practical than ISO).&lt;/P&gt;</description>
      <pubDate>Wed, 04 Sep 2019 14:48:53 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/abap-character-encoding-conversion/m-p/12046403#M1968366</guid>
      <dc:creator>Sandra_Rossi</dc:creator>
      <dc:date>2019-09-04T14:48:53Z</dc:date>
    </item>
  </channel>
</rss>

