Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

How to convert to UTF-16 before transfer

Former Member
0 Kudos
582

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.

3 REPLIES 3

Former Member
0 Kudos
224

Hi,

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

uwe_schieferstein
Active Contributor
0 Kudos
224

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

0 Kudos
224

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