Skip to Content
0
Former Member
Jun 09, 2009 at 09:55 AM

OPEN DATASET problem with UTF-8

3568 Views

Hi frnds,

Problem details: We have to read file from applicaitn server, In the file data its having special characters like "Uherské Hradiu0161te". when i m trying to read the file, Data is comming but the special character are not comming, inthe place of special characters its giving spcae r #..

Below is the code i m trying

************************************************************************************************

DATA: lw_filepath TYPE rlgrap-filename value '/011/test.txt', " application server path.

lw_empty TYPE flag,

lw_lineno(8) TYPE c,

index TYPE i,

infile(1500) TYPE C.

*Read the file from the application server and put the records into the INFILE internal table

  • Open File

OPEN DATASET lw_filepath IN TEXT MODE FOR INPUT ENCODING UTF-8 REPLACEMENT CHARACTER space.

*OPEN DATASET lw_filepath IN legacy text MODE for INPUT.

*OPEN DATASET lw_filepath IN TEXT MODE FOR INPUT ENCODING DEFAULT.

  • OPEN DATASET lw_filepath IN TEXT MODE FOR INPUT ENCODING DEFAULT REPLACEMENT CHARACTER space.

  • OPEN DATASET lw_filepath IN TEXT MODE ENCODING UTF-8 set-loacal lange iwth countery key FOR INPUT REPLACEMENT CHARACTER space.

IF sy-subrc <> 0.

RAISE open_failure.

ENDIF.

  • Initialize empty file flag

lw_empty = 'X'.

  • Read the rest of the records until EOF

DO.

CLEAR infile.

TRY.

READ DATASET lw_filepath INTO infile.

CATCH cx_sy_conversion_codepage.

ENDTRY.

WRITE: / infile.

if infile is initial.

exit.

endif.

ENDDO.

  • Close file

CLOSE DATASET lw_filepath.

***************************************************************************************

Below is the applicaiton server file data: test.txt having some special characters

Velký Velký Hložkova Nádražní Želechovice Uherské Hradiu0161teZlín Mládí