about Chinese characters when generate file and download from AL11
It’s not convenient to use files generated at the server side then let the user download file from AL11 compared with generating files at local or get files as attachments from email. But sometimes has to use this method as email attachments could exceed the Maximum attachment size limit or time out issue when running front-end.
Here, small tips about generating/downloading files which contain Chinese characters from AL11:
Generate file at AL11 using ‘open dataset’
open dataset gs_outfile for output in text mode encoding default.
Download file at AL11 using CG3Y
We have two options here which are ASCII format and Binary format. There’re many articles that tell the difference between Binary and ASCII like this and this one. Here just list few points from my own perspective:
- Output file extension could be TXT or DAT. Please do not add file extensions like XLS, XLSX which can’t open by Excel or notepad.
- BIN file is much larger than the ASCII file. For my example, it’s 800KB vs 280KB. After converting the BIN/ASCII formatted file from DAT/TXT to EXCEL, it’s 307KB vs149KB.
- Both BIN and ASCII can display Chinese characters correctly when opening with a notepad. But ASCII could be truncated if lots of columns! So always use BIN instead of ASCII for download.
- It’s not a good approach to open the converted file by excel directly. Instead, try using Open->new file, Excel will popup text import wizard, and suggest 65001(UTF-8) by default.
- There’re two types of errors when displaying Chinese characters after converting to DAT/TXT file(other English text and numbers are showing correctly, not a messy file): one is show # for all Chinese characters, another one is showing messy code for all Chinese characters.
- # means the file has been generated incorrectly, check the file generation logic. Messy code could be a conversion issue, check the convert logic or convert procedure after generation. Notepad provides the function to save a file as <UTF-8 with BOM>. Just have a try if have a second type error.
- Besides Chinese characters, it could be the same issue for Japanese characters or any language using Double Byte Character Sets (DBCS) as well. If using the program to download those files from AL11 by some FM, please consider the code page accordingly.