cancel
Showing results for 
Search instead for 
Did you mean: 

Translate statement in UNICODE

Former Member
0 Kudos

Hi,

we are working on SAP Upgrade, so as is known TRANSLATE statement is obsolete in Unicode. The code that was being used in non-unicode is:

data: line(500).
open dataset i_file for input in text mode.
if sy-subrc <> 0.
  raise i_file_not_found.
endif.

open dataset o_file for output in text mode.
if sy-subrc <> 0.
  raise o_file_not_found.
endif.

do.
  read dataset i_file into line.
  if sy-subrc <> 0.
    exit.
  else.
    translate line from code page '1504' to code page '1500'.
    replace ';' with ',' into line.
    transfer line to o_file.
  endif.
enddo.

close dataset i_file.
close dataset o_file.


Now I need to put ENCODING for the dataset statement and also change the translate statement. My question is which encoding should I use and which code pages. (now our system is 4103 and code page on front-end 4110). If somebody has had this type of problem during upgrade, please help me.


Thanks! 🙂

matt
Active Contributor

Please in future use the "code" button in the editor when posting code. When pasting from an editor, use right-click "paste as plain text".

I've edited your post for you this time.

Former Member

Thanks! It's my first time posting here, didn't know it.

matt
Active Contributor
0 Kudos

No problem. Many people make the same error at first. 🙂

Accepted Solutions (0)

Answers (1)

Answers (1)

NTeunckens
Active Contributor

Do some tests using Class "CL_ABAP_CONV_OBJ" to enable conversion to Unicode : see this Wiki / this Wiki

Former Member
0 Kudos

but as I can see, when I read the data in the Unicode system is already converted, all the characters are right, but the problem is transferring into the output file in AL11, when I open it, it has #, not the converterted data. I think that my problem is in this statement

open dataset o_file for output in textmode.

Now as encoding I have NON-Unicode, but it's not shown good.

SimoneMilesi
Active Contributor

Exactly: check your help and see the various options on Encoding.

Hint: DEFAULT IGNORING CONVERSION ERRORS.

Former Member
0 Kudos

I can see in debug that because of the # symbol, I have a character set conversion error.

All the others rows from the file are read right pa in the output file are again represented with #.

Any help about these two problems?

Thank you!

Former Member

Hi, simone.milesi ,

open dataset o_file for output in text mode encoding default ignoring conversion errors.

is the right solution for my problem. Thank you again!

SimoneMilesi
Active Contributor
0 Kudos

I'm happy you solved the issue, but it's something well known and already discussed on the Community.

Next time, try to give a look with google or the search here: often the previous posts have more detailed infos 🙂