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

How control the filename encoding when using open dataset?

Former Member
0 Likes
5,215

Hi all,

We are using opendatset to create file on Linux server. The SAP system is Unicode and filename created is encoded in unicode as well. However, when we transfer that file to a Windows machine, the file appears illegible with special characters. The original file name is in Hebrew.

Any ideas as to how to control the encoding of the file name itself using "open dataset <filename>"?

Best Regards,

Eric Labiner

14 REPLIES 14
Read only

kjyothiraditya
Participant
0 Likes
2,848

Hi Eric,

try to create file using 'ENCODING' statement addition in OPEN DATASET (ABAP Keyword Documentation) .

Or else try to download file to windows system as binary file with appropriate file extension.

Also check in your system if additional languages are supported.

Please reward if helpful.

Regards,

Aditya

Read only

0 Likes
2,848

Hi Aditya,

We have tried all of the combinations for the ENCODING and I can see that it affects the encoding of the contents of the file and not the encoding of the file name.

Eric

Read only

0 Likes
2,848

Hi ERic,

Thanks for your reply. Try to open the file using MS office applcn or some other applcn. Also check the font settings in your system while opening the file. Choose text encoding when you open and save files - Word

Read only

0 Likes
2,848

Hi Aditya,


All the apps I use to open the files show the contents fine. Our problem is how to control the encoding of the file name itself.


Eric

Read only

Sandra_Rossi
Active Contributor
0 Likes
2,848

So I guess you made sure that the file name is correct at the application server.

How do you transfer the file at the frontend?

On that frontend, did you try to create a file from scratch with name in Hebrew?

Read only

0 Likes
2,848

Hi Sandra,

The file is transferred using FTP. On the application server we see the file fine, in Hebrew. If I create the file on the frontend with a Hebrew filename I see it fine, but that's because windows encodes the filenames with codepage 1255 and not Unicode.

Eric

Read only

0 Likes
2,848

So, the issue is probably due to your FTP software, which doesn't "detect" the file name encoding of at least one of your 2 file systems. You should search the web, not the SAP forum. Except if you use FTP from SAP? What exactly then?

Message was edited by: Sandra Rossi RFC 2640 (https://tools.ietf.org/html/rfc2640) gives more details about FTP client/server softwares how they should treat encoding of file names - the recommendation is to use UTF-8, but do your FTP client/server works this way? there is the FTP command FEAT to know if UTF8 is supported, and LANG to force an encoding.

Read only

Former Member
0 Likes
2,848

Hi Eric,

Try to use this

OPEN DATA SET G_FILE FOR INPUT IN TEXT MODE ENCODING DEFAULT IGNORING                                                                               CONVERSION ERRORS.

Hope this may help full.

Regards,

E.Ananthachari.

Read only

0 Likes
2,848

Hello,

Thanks for the idea. I tested your idea and with the same results. It appears that the encoding parameters are only relevant for the file's contents and not the file name itself.

Eric

Read only

nils_buerckel
Product and Topic Expert
Product and Topic Expert
0 Likes
2,848

Hi Eric,

I never heard about an option in ABAP to control the encoding of a file name when creating a file. I assume it is not possible to change the standard behaviour - UTF-8 for Unicode systems and Non-Unicode (code page depends on the system code page) for Non-Unicode systems.

I could imagine that you can do a conversion when transferring the file via ftp - but unfortunately I do not have details. The other option would be to change the encoding on OS side ...

Best regards,

Nils Buerckel

Read only

Juwin
Active Contributor
0 Likes
2,848

Hi Eric,

When you try to open the file in AL11, what happens? Does it open the file correctly and display the contents? If yes, then you should to check how AL11 is able to open the file using OPEN DATASET and use the same logic in your program. If AL11 isn't able to read the file, then I guess you are out of luck.

Thanks,

Juwin

Read only

Former Member
0 Likes
2,848

Hi Juwin,

In AL11, the file name and contents are displayed fine. This is expected - as Linux is able to handle well unicode file names and the SAP system is unicode as well. I am also able to see the file name fine when looking at it on the operating system level.

The problem is reading the file name on a windows machine. Windows expects the file name to be encoded in Win-1255 codepage and doesn't check for encoding of the file name,

Regards,

Eric

Read only

PeterJonker
Active Contributor
0 Likes
2,848

I had many problems before with encoding and special characters Turkish and greek letters). The following statement solved all of them:

OPEN DATASET l_file FOR OUTPUT IN TEXT MODE ENCODING UTF-8 WITH BYTE-ORDER MARK.


Try it to see if it solves your problems as well.


Regards,


Peter

Read only

balbino_soaresferreirafil
Active Participant
0 Likes
2,848

It is a operational system issue, you can't correct this using abap. But, ask your system administrator to check about character encoding on linux. It is a common issue in copies between linux and windows.

There is a tool that converts the file encoding

To remove the “(invalid encoding)” you use the “convmv” tool. It is a tool that will convert the character encoding used in the file name. You can try the conversion of file names from different character set to UTF-8 using the following commands:


convmv -r -f windows-1252 -t UTF-8 .

convmv -r -f ISO-8859-1 -t UTF-8 .

convmv -r -f cp-850 -t UTF-8 .

Try to create a job in linux server that run this commands in determinate times, or ask the system administrator, about another solution.

I hope this can help you.

Regards,