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

Read Dataset exporting wrong characters

mrio_espinheira
Participant
0 Likes
1,210

Hi,

I have two reports, one that creates files on the application server, and another that reads the contents of the files and shows them using the WRITE instruction.

When I use the first report and then download the file to my computer (using CG3Y) everything is alright. But when I use the second report some of the characters (Portuguese special characters, e.g. á, ã, é, etc.) that are shown are wrong:

Original:

2B002AG0262350100000660000000100020REF_002 Joaquim Neves Transf. Bancária Indeminização

Output:

2B002AG0262350100000660000000100020REF_002 Joaquim Neves Transf. Bancária Indeminização

The code I'm using to read the files and show their data is:

  • abrir ficheiro

open dataset lv_filename for input

in text mode

encoding default.

if sy-subrc eq 0.

  • exportar todos os registos para o ecran

do.

clear lv_output.

read dataset lv_filename into lv_output

maximum length lv_length.

if sy-subrc eq 0.

write lv_output.

else.

exit.

endif.

enddo.

endif.

close dataset lv_filename.

Can anyone help me on this?

Best regards,

Mário Espinheira

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
938

Hi Mario,

I presume this is due to the GUI problem.

Do as specified below. Hope this should solve the issue.

ALt+F12-> Options>I18N---> Check the Activate the multibyte functionalities

Then restart ur PC and try downloading.

Let me know If you still have any issues.

7 REPLIES 7
Read only

Former Member
0 Likes
939

Hi Mario,

I presume this is due to the GUI problem.

Do as specified below. Hope this should solve the issue.

ALt+F12-> Options>I18N---> Check the Activate the multibyte functionalities

Then restart ur PC and try downloading.

Let me know If you still have any issues.

Read only

0 Likes
938

It didn't work, the contents of the files are still shown with the wrong special characters.

Thanks for the suggestion anyway

Read only

0 Likes
938

Hi Mario,

I presume your environment is Unicode.

In Unicode programs, only the content of character-type data objects can be transferred to text files and read from text files. The addition encoding must be specified in Unicode programs, and can only be omitted in non-Unicode programs. 

OPEN DATASET filename FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.

OR

Try using method gui_upload of class cl_gui_front_end_services instead of open dataset.

Read only

0 Likes
938

Hello,

I'm already opening the dataset as you said, and the class CL_GUI_FRONTEND_SERVICES only works with files from the Client PC, not with files from the Application Server like I need it.

Kind regards,

Mário Espinheira

Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
938

I tried with UTF-8 encoding & seems to work for me.

DATA: v_asfile TYPE fileextern VALUE '/tmp/Unicode.txt',
      v_string TYPE string.

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

DO.
  READ DATASET v_asfile INTO v_string.
  IF sy-subrc = 0.
    WRITE / v_string.
  ELSE.
    EXIT.
  ENDIF.
ENDDO.

BR,

Suhas

Read only

0 Likes
938

Hello,

Tried with encoding UTF-8 and it worked also. Full points awarded.

The problem was reading a backup file that was copied using FM EPS_FTP_PUT. When I read the original file it's all ok.

Thank you!

Edited by: Mario Espinheira on Sep 23, 2010 12:18 PM

Read only

Former Member
0 Likes
938

Hi ,

Check with your basis guy if the code page what is set is having these special characters.

Code Page transaction SCP.

Br,

Vijay