Application Development 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: 

How to read a Unicode text file in a non-unicode SAP system

Former Member
0 Kudos

I'm currently has a text file which is saved as UTF-8 format. And inside this file has Thai characters.

However, my SAP system is a non-unicode system.

When I use the code

open dataset DSN for output in TEXT MODE encoding UTF-8

the thai characters become some funny characters.

How can I solve this in the ABAP program without changing the system from non-unicode to unicode system?

1 ACCEPTED SOLUTION

anversha_s
Active Contributor
0 Kudos

hi,

u can transalte the charatcter to english.

then use open data set.

rgds

anver

9 REPLIES 9

anversha_s
Active Contributor
0 Kudos

hi,

u can transalte the charatcter to english.

then use open data set.

rgds

anver

0 Kudos

do you have the coding for translate to english.

When I open dataset, which mode should I use? Text mode encoding default?

anversha_s
Active Contributor
0 Kudos

hi

hk this.

Just see the usage of LXE_PP1_TRANSLATION_EVAL_SE63 in include pgm LSKTYF01

this may hlp u.

rgds

anver

if hlped mark points

0 Kudos

Dear Irene

As the orginal file is in UTF-8 format, we can use the same to open the file.

But to be able to read the Thai characters, code page for THAI has to be installed in SAP to recognize the same. Please ask your Basis consultant to install the same and see.

Hope the above info helps you.

Kind Regards

Eswar

0 Kudos

Hi Eswar,

How can I check whether the code page for THAI already installed or not in SAP system?

Here is the code I use to test to read a file that saved as UTF-8.

DATA: l_filepath TYPE string.

DATA : BEGIN OF l_filepath_str OCCURS 0,

comm(1000) TYPE c,

END OF l_filepath_str.

DATA: l_datasetsucc LIKE rlgrap-filename.

l_filepath = '/BAAC/Files/APP_.txt'.

OPEN DATASET l_filepath FOR INPUT IN TEXT MODE ENCODING UTF-8.

IF sy-subrc EQ 0.

DO.

CLEAR l_filepath_str.

READ DATASET l_filepath INTO l_filepath_str.

IF sy-subrc EQ 0.

APPEND l_filepath_str.

ELSE.

EXIT.

ENDIF.

ENDDO.

ELSE.

WRITE:/ 'Error reading from file:', sy-subrc.

ENDIF.

CLOSE DATASET l_filepath.

LOOP AT l_filepath_str.

WRITE: / l_filepath_str-comm.

ENDLOOP.

It returns me a runtime error. Any idea?

0 Kudos

hi,

chk this sample.

parameters: p_file like rlgrap-filename obligatory

default '/usr/sap/upload.xls'.

types: begin of t_data,

vbeln like vbap-vbeln,

posnr like vbap-posnr,

matnr like vbap-matnr,

werks like vbap-werks,

megne like vbap-zmeng,

end of t_data.

data: it_data type standard table of t_data,

wa_data type t_data.

open dataset p_file for output in text mode encoding default.

if sy-subrc ne 0.

write:/ 'Unable to open file:', p_file.

else.

do.

read dataset p_file into wa_data.

if sy-subrc ne 0.

exit.

else.

append wa_data to it_data.

endif.

enddo.

close dataset p_file.

endif.

rgds

anver

0 Kudos

Hi Anversha,

I think the code you give will show me the unknown characters also.

is the class CL_ABAP_CONV_IN_CE will be helpful to solve my issue?

0 Kudos

Dear Irene

Please check table TCP00 for codepages catalog.

Kind Regards

Eswar

Former Member
0 Kudos

Hi Irene.....

Hope you are fine. I am also facing the same problem as posted in this post. Could you please let me know how you resolved your problem.

Your help is much appreciated.

Yogesh