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

Unicode error : TRANSLATE obsolete!!

Former Member
0 Likes
943

hi experts!

I'm trying to migrate from 4.6C to ECC 6.0 all the programs.

I had a problem with the below statement:

TRANSLATE st_enr-record from code page '0100' to code page '1110'.

Can anyone tell me which class/method and how to use it?

Thanks!

Tarick.

4 REPLIES 4
Read only

Former Member
0 Likes
710

Hello,

This variant of the TRANSLATE statement is not allowed in Unicode programs. Their functions are replaced with methods of the following conversion classes:

CL_ABAP_CONV_IN_CE -Reading data from a byte-like data object and converting from an external format to the system format.

CL_ABAP_CONV_OUT_CE - Converting data from the system format to an external format and writing in a byte-like data object.

CL_ABAP_CONV_X2X_CE - Converting data from an external format to another external format.

Regards,

Read only

Former Member
0 Likes
710

Hi Mouhamad,

Translate is Obsolete now . You need to use Classes

CL_ABAP_CONV_IN_CE - External to System Format

CL_ABAP_CONV_OUT_CE - System Format to External Format.

you refer the following code also.

report znk_sdn.

data : in_buffer type xstring,

out_buffer type xstring,

conv type ref to cl_abap_conv_x2x_ce,

str1 type string value '?',

x type xstring.

convert text str1 into sortable code x.

write: x, ' '.

convert text '-' into sortable code x.

write x.

in_buffer = '414220C3B602010000'.

conv = cl_abap_conv_x2x_ce=>create( in_encoding = 'UTF-8'

in_endian = 'L'

out_encoding = '1100'

out_endian = 'B'

input = in_buffer ).

call method conv->convert_c( n = 5 ).

out_buffer = conv->get_out_buffer( ).

write out_buffer.

Award points if useful

Ravee..!

Read only

Former Member
0 Likes
710

Thanks to both of u!

But,

It's very difficult for me to put my coding inside the class u pointed out, can u please tell me how to use this method with code pages '0100' and '1110' ? Here's the coding:

DATA : BEGIN OF st_enr,

pernr LIKE pernr-pernr,

index(4) TYPE n,

ltype(2),

record(98),

END OF st_enr.

TRANSLATE st_enr-record FROM CODE PAGE '0100' TO CODE PAGE '1110'

Please help me, its very urgent!

Tarick.

Read only

Former Member
0 Likes
710

problem solved! thanks to everyone!

Here's the code for people who may have the same problem :

DATA : g_codepage LIKE tcp0c-charco VALUE '0100'.

CONSTANTS: c_unicodecp(4) VALUE '1110'.

DATA: converter TYPE REF TO cl_abap_conv_obj.

DATA: l_out TYPE string.

DATA: l_fromcode TYPE cpcodepage.

DATA: l_tocode TYPE cpcodepage.

l_fromcode = g_codepage.

l_tocode = c_unicodecp.

CREATE OBJECT converter

EXPORTING

incode = l_fromcode

miss = '.'

broken = '.'

use_f1 = 'X'

outcode = l_tocode

EXCEPTIONS

invalid_codepage = 1

internal_error = 2.

IF sy-subrc eq 0.

CASE sy-subrc.

WHEN 1.

MESSAGE ID 'FES' TYPE 'E' NUMBER '024' RAISING unknown_error.

WHEN 2.

MESSAGE ID 'FES' TYPE 'E' NUMBER '024' RAISING unknown_error.

ENDCASE.

ENDIF.

CALL METHOD converter->convert

EXPORTING

inbuff = st_enr-record

inbufflg = 0

outbufflg = 0

IMPORTING

outbuff = l_out

EXCEPTIONS

internal_error = 1

OTHERS = 2.

IF sy-subrc eq 0.

CASE sy-subrc.

WHEN 1.

MESSAGE ID 'FES' TYPE 'E' NUMBER '024' RAISING unknown_error.

WHEN 2.

MESSAGE ID 'FES' TYPE 'E' NUMBER '024' RAISING unknown_error.

ENDCASE.

ENDIF.

st_enr-record = l_out.