Application Development and Automation 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: 
Read only

File encoding

Former Member
0 Likes
1,317

Hi friends,

Will "OPEN DATASET dsn FOR INPUT IN TEXT MODE ENCODING NON-UNICODE" cause any problem when reading a UNICODE file? Do you have idea how to check the encoding of the file? Thanks.

Thanks, gk

5 REPLIES 5
Read only

Former Member
0 Likes
1,113

Hello,

Please follow the given syntax:

OPEN DATASET dataset_name FOR access IN TEXT MODE ENCODING DEFAULT.

Regards,

Vaibhav Singhania

Read only

0 Likes
1,113

Thanks Vaibhav Singhania.

"OPEN DATASET dataset_name FOR access IN TEXT MODE ENCODING DEFAULT." will cause issue when reading a NON-UNICODE text file.

My program is used to read a UNIX text file and then download it to the local PC.

The UNIX text file may contains special character such as "é". If i used this statement (OPEN DATASET dsn FOR INPUT IN TEXT MODE ENCODING DEFAULT), it will hit CONVT_CODEPAGE runtime error. If i used this statement (OPEN DATASET dsn FOR INPUT IN TEXT MODE ENCODING DEFAULT IGNORING CONVERSION ERRORS.), although it did not hit CONVT_CODEPAGE runtime error, but when i checked the downloaded text file, i found that the special character "é" appears as "#".

Read only

nils_buerckel
Product and Topic Expert
Product and Topic Expert
0 Likes
1,113

Hi,

you need to select the Unicode option in case of a utf-8 based file and the Non-Unicode option (+ correct logon language - sy-langu) in case of a Non-Unicode one.

If this does not fit, you get either an error, Hashes ("#") or Gibberish  ...

Best regards,

Nils Buerckel

Read only

Clemenss
Active Contributor
0 Likes
1,113

Hi gk,

if your program does nothing else but read from server and download to client, try binary mode.

Or just use function module  ARCHIVFILE_SERVER_TO_CLIENT. Simple. Too simple?

Regards

Clemens

Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
1,113

gk goh wrote:

... Do you have idea how to check the encoding of the file? ...

You can use the methods of the class CL_ABAP_FILE_UTILITIES to check the encoding of an app server file. Read the individual method documentation for details on how to use this class. Based on the encoding info you get from the class you can use the proper ENCODING option with OPEN DATASET.

Else as suggested by you can use the BINARY MODE option & forget about the file encoding.

BR,

Suhas

Message was edited by: Suhas Saha