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

GUI_DOWNLOAD codepage

Former Member
0 Likes
7,127

Hello Abapers,

I am using GUI_DOWNLOAD to save data (which will be displayed in an ALV) in an EXCEL file.

The program need to be translated into PL language therefore, I think that the CODEPAGE parameter need to be indicated while using GUI_DOWNLOAD. I am using the FM NLS_GET_FRONTEND_CP to generate the CODEPAGE. But the polish special characters does not well display in the excel file.

What do you people suggest me as solution to solve this problem?

Thanks you in advance.

Fehmida

Hello Abapers,

I am using GUI_DOWNLOAD to save data (which will be displayed in an ALV) in an EXCEL file.

The program need to be translated into PL language therefore, I think that the CODEPAGE parameter need to be indicated while using GUI_DOWNLOAD. I am using the FM NLS_GET_FRONTEND_CP to generate the CODEPAGE. But the polish special characters does not well display in the excel file.

What do you people suggest me as solution to solve this problem?

Thanks you in advance.

Fehmida

3 REPLIES 3
Read only

JL23
Active Contributor
0 Likes
1,851

use function module NLS_GET_FRONTEND_CP to determine the code page of your front end.

Read only

0 Likes
1,851

Hi jrgen.lins,

I tried this FM to get the codepage value for a language and passed that code page value to cl_gui_frontend_services=>gui_upload, but it is still not working.

Please help me on this, actual code is as below,

DATA: lv_CPCODEPAGE TYPE CPCODEPAGE,
lv_ABAP_ENCOD TYPE ABAP_ENCOD.


CLear lv_CPCODEPAGE.
CALL FUNCTION 'NLS_GET_FRONTEND_CP'
EXPORTING
langu = p_langu
FETYPE = 'MS'
IMPORTING
FRONTEND_CODEPAGE = lv_CPCODEPAGE
EXCEPTIONS
ILLEGAL_SYST_CODEPAGE = 1
NO_FRONTEND_CP_FOUND = 2
INTERNAL_OR_DB_ERROR = 3
OTHERS = 4
.
IF sy-subrc <> 0.
* Implement suitable error handling here
ELSE.
lv_ABAP_ENCOD = lv_CPCODEPAGE.
ENDIF.

CALL METHOD cl_gui_frontend_services=>gui_upload
EXPORTING
filename = gv_kna1
filetype = 'ASC'
codepage = lv_ABAP_ENCOD "lv_CPCODEPAGE "'UTF-8' "'4102'
has_field_separator = 'X'
CHANGING
data_tab = lt_kna1.
LOOP AT lt_kna1 ASSIGNING <fs_kna1>.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = <fs_kna1>-kunnr
IMPORTING
output = <fs_kna1>-kunnr.
<fs_kna1>-erdat = sy-datum.

Read only

Former Member
1,851

Thanks for the reply.

Below the a sample code to solve the problem:

CALL FUNCTION 'SCP_CODEPAGE_BY_EXTERNAL_NAME'

EXPORTING

external_name = 'UTF-16LE'

kind = 'H'

IMPORTING

sap_codepage = code

EXCEPTIONS

not_found = 1

OTHERS = 2.

IF sy-subrc <> 0.

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ELSE.

WRITE code TO codepage.

ENDIF.

CALL FUNCTION 'GUI_DOWNLOAD'

EXPORTING

filename = p_file

filetype = 'DAT'

codepage = codepage

write_bom = 'X'

TABLES

data_tab = header

Best regards,

Fehmida