Skip to Content
avatar image
Former Member

GUI Download Chinese Character to Excel gibberish character

Hi Experts,

I'm facing a problem where I'm using FM gui_download to save Chinese Character into Excel file.

Upon double click to open the excel file, funny character shows up.

But if I were to open the same file using a blank Ms Excel application (Go to File->Open->choose file),

Excel will prompt me to select a proper encoding (GB2312 in this case), and the Chinese character can be seen thereafter.

But, my user doesn't want to go through this.

I've browsed through the forum and someone has posted about this before and it's unanswered.

how-to-download-the-chinese-character-using-guidow - unanswered

And, guidownload-give-2-bytes-for-each-chinese-characte which is not related to my problem.

Below is my code:

DATA: lv_codepage TYPE cpcodepage,

lv_char_cpage TYPE abap_encod,

lv_encoding TYPE abap_encod.

  • Get Code Page for Chinese Character Spras = '1' or 'ZH'

CALL FUNCTION 'NLS_GET_FRONTEND_CP'

EXPORTING

langu = '1' " Chinese Simplified Table T002

fetype = 'MS' " Manufacturer is Microsoft Table TCP05

IMPORTING

frontend_codepage = lv_codepage

EXCEPTIONS

illegal_syst_codepage = 1

no_frontend_cp_found = 2

internal_or_db_error = 3

OTHERS = 4.

  • Conversion c(4) = n(10)

lv_char_cpage = lv_codepage.

CALL FUNCTION 'GUI_DOWNLOAD'

EXPORTING

filename = p_file

filetype = 'DAT' "tried ASC and not working as well

codepage = lv_char_cpage "8404 in this case tried 8400 and same result

replacement = '#'

write_field_separator = 'X'

TABLES

data_tab = i_data_cnvr "table content

fieldnames = i_data_head "table header

Please help. Does this has something to do with utf-8 encoding?

Thank you.

Thanks,

ZY See

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • avatar image
    Former Member
    Jul 14, 2009 at 02:58 AM

    GUI_DOWNLOAD codepage = '4103' write_bom = 'X' for Chinese Character Download.

    Add comment
    10|10000 characters needed characters exceeded

  • Jul 13, 2009 at 11:17 AM

    Hi,

    This normally happens if the codepage being used in Excel to open the file is not adequate.

    Kindly choose the correct codepage in Excel. In case you do not know the same, try opening the file with the different Chinese codepages available in Excel and your file will open correctly with one of the Chinese codepages.

    regards

    Nitesh

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hi Nitesh,

      Is there a way to check the Excel codepage? Do you mean by codepage = 936 for GB2312 encoding?

      Anyway, this issue is fixed. Issue is related to unicode system.

      Below codes for gui_download solved the problem.

      CALL FUNCTION 'GUI_DOWNLOAD'

      EXPORTING

      filename = p_file

      filetype = 'DAT'

      codepage = '4103'

      replacement = '#'

      write_field_separator = 'X'

      write_bom = 'X'

      TABLES

      data_tab = i_data_cnvr

      fieldnames = i_data_head

      Codepage = 4103 for utf-16 Unicode system.

      Write-bom = 'X' to write Byte-Order-Mark.

      Thanks,

      ZY See