2009 Jun 09 10:55 AM
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í
2009 Jun 09 11:40 AM
Hi,
Incase you need the special characters you will have to use ENCODING as UTF-8.
if you use the encoding as NON-UNICODE; then you special characters will be converted into #.
This is because as per UNICODE standards special charaters require 2 byte of memory space.
Regards,
Ankur Parab
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í
2009 Jun 09 10:58 AM
try this
OPEN DATASET lw_filepath IN TEXT MODE FOR INPUT ENCODING NON-UNICODE
2009 Jun 09 11:06 AM
Thanks for responding krishna murty,
I tried that also, still i m getting # in place of some spl characters.
2009 Jun 09 11:06 AM
Hello,
I tried using
OPEN DATASET lw_filepath FOR INPUT IN TEXT MODE ENCODING DEFAULT.And i have the data after READ DATASET. Can you plz clarify why you need ENCODING UTF-8?
BR,
Suhas
2009 Jun 09 11:19 AM
Hi
I tried with OPEN DATASET lw_filepath FOR INPUT IN TEXT MODE ENCODING DEFAULT this also.
but its now roking.
we need to read UNICODE data. can u check the test data, above i provided
2009 Jun 09 11:28 AM
Hello,
I tried with your test data only & it is working fine for me. BTW what do you mean by :
we need to read UNICODE data
Plz revert back.
2009 Jun 09 11:40 AM
can you suggest me i need changes setting in SAP logoin or any properties
In my system logon -> change item-> in that Code page tab.
Language is Default and Unicode off check box is unchecked.
upload/download Encoding is "default - ANSI for Unicode system"
can you tel me u r settings
2009 Jun 09 11:51 AM
Hello,
You hit the nail right on the head ) The encoding must be "Default - ANSI for Uinicode systems".
Hope this helps.
BR,
Suhas
2009 Jun 09 11:06 AM
HI,
SAP offers F1 help too.. just press F1 on OPEN DATASET !
then on ENCODING DEFAULT..... should work for you.
for more info, F1.
Regards, Bin
2009 Jun 09 11:40 AM
Hi,
Incase you need the special characters you will have to use ENCODING as UTF-8.
if you use the encoding as NON-UNICODE; then you special characters will be converted into #.
This is because as per UNICODE standards special charaters require 2 byte of memory space.
Regards,
Ankur Parab
2009 Jun 09 11:48 AM
Hi Ankur Parab ,
s i m using UTF-8, but its not working. In the place of spl character its comming space or # symbol.
below is the stmt
OPEN DATASET l_filepath IN TEXT MODE FOR INPUT ENCODING UTF-8 REPLACEMENT CHARACTER space.
2009 Jun 09 11:54 AM
>
> Hi,
> Incase you need the special characters you will have to use ENCODING as UTF-8.
> if you use the encoding as NON-UNICODE; then you special characters will be converted into #.
>
> This is because as per UNICODE standards special charaters require 2 byte of memory space.
>
> Regards,
> Ankur Parab
Hello Ankur,
And on what basis are you claiming this?
BR,
Suhas
2009 Jun 09 12:15 PM
Hi,
Please do F1 on UTF-8
UTF-8
8 bit Unicode character representation. ASCII characters are represented by one byte. Other European characters are represented in 2 bytes. Most Asian characters are represented in 3 bytes. The characters in the surrogate area are addressed directly using 4 bytes.
Regards,
Ankur Parab
2009 Jun 09 12:23 PM
Thanks Ankur Parab,
we have to use UTF-16 for this problem. but can u plz explain me how can i use this formate in my ABAP program.
below one i m using.
OPEN DATASET lw_filepath IN TEXT MODE FOR INPUT ENCODING UTF-8 REPLACEMENT CHARACTER space.
UTF-8 because of this the spl character are not comming. how can i use UTF-16 in my program.
2009 Jun 09 1:29 PM
Hello Ankur,
You may be aware of something called Code Page. This is where code-page comes into picture. Differenet character sets have different Code Page representations.
I think what you are talking about is Code Page & not encoding.
Hope i am clear.
BR,
Suhas
2009 Jun 09 11:49 AM
Some of the languages "Code pages" are not supported in "EN" login. Try loggin in into corresponding language log in (RU for Russia, RO for Romania etc..).
2009 Jun 09 11:59 AM
To avoid # use,
REPLACE ALL OCCURRENCES OF '#' IN infile WITH 'Special Character'.Thanks and Regards
| User | Count |
|---|---|
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |