‎2008 Apr 02 2:33 PM
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.
‎2008 Apr 02 3:09 PM
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,
‎2008 Apr 02 11:38 PM
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..!
‎2008 Apr 03 8:06 AM
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.
‎2008 Apr 03 9:24 AM
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.