Skip to Content
author's profile photo Former Member
Former Member

How to convert to UTF-16 before transfer

getting ABAP dump CONVT_CODEPAGE in ECC 6.0

While reading data from Unix file it is giving dump

I feel while transfering into Unix the data should be converted

how to convert the data?

The pseudo code is as shown below,

OPEN DATASET OUTFILE FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.

CHECK SY-SUBRC = 0.

loop at internale table.

transfer <internal table values> to outfile.

endloop.

CLOSE DATASET OUTFILE.

OPEN DATASET infile FOR INPUT IN TEXT MODE ENCODING DEFAULT.

IF sy-subrc <> 0.

WRITE: / 'Could not open input file ', infile.

STOP.

ENDIF.

do.

READ DATASET infile INTO <workarea>.

enddo.

CLOSE DATASET infile.

Add a comment
10|10000 characters needed characters exceeded

Related questions

2 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Dec 01, 2007 at 04:44 PM

    Hi,

    Did you get thte solution for this error? Please let me know. Thanks

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Dec 01, 2007 at 10:14 PM

    Hello Sreedevi

    Using static methods

    CHECK_FOR_BOM
    CHECK_UTF8

    of class <b>CL_ABAP_FILE_UTILITIES</b> you should be able to find out the encoding of your Unix file (UTF16, little endian / big endian).

    If the problem is indeed that the file is UTF16 whereas the OPEN DATASET expects UTF-8 you probably have to use class <b>CL_ABAP_CONV_IN_CE</b> (<i>Codepage & Endian conversion; External -> system format</i>).

    I would assume that you need to read the file IN BINARY MODE and then use the method of the converter class to retrieve the appropriate encoding.

    Finally, have a look at the blog

    <a href="/people/ulrich.brink/blog/2005/08/18/unicode-file-handling-in-abap File Handling in ABAP</a>

    Perhaps you will find another solution there.

    Regards

    Uwe

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hello,

      If the sap system is set to UTF-16, you could also try a different solution.

      Read the file in binary mode, into a field of type C with the exact length of one record (end-of-line not recognized in binary mode). If you do this, conversion from UTF-16 is done automatically. Than you can just move the C-field into the wanted structure. Note that the last 2 characters can be carriage return and line feed characters.

      The same applies to writing a file: just write it in binary mode, and UTF-16 will be used if the system is set to use it.

      Kind Regards,

      Bart

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.