Application Development 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: 

Problem in Unicode Conversion

Former Member
0 Kudos

Hello Experts,

As TRANSLATE is obsolate in Unicode version(4.7).. I am using following code to Replace translate.

But The data is not getting translated. Please help.

TYPES: BEGIN OF g_ty_packed,

ttnr(10) TYPE c,

zuord(2) TYPE c,

fuel1(18) TYPE c,

prozent(7) TYPE c,

fuel2(20) TYPE c,

werk(3) TYPE c,

fuel3(20) TYPE c,

END OF g_ty_packed.

DATA: l_view TYPE REF TO cl_abap_view_offlen.

DATA: g_s_packed TYPE g_ty_packed.

DATA: lf_len_x TYPE i,

lo_conv TYPE REF TO cl_abap_conv_in_ce,

l_buffer TYPE xstring.

DATA: lr_conv TYPE REF TO cl_abap_conv_in_ce,

l_xfeld TYPE xstring,

l_encoding TYPE abap_encoding.

FIELD-SYMBOLS: <xfeld>.

ASSIGN g_s_packed TO <xfeld> TYPE 'X'.

l_xfeld = <xfeld>.

lr_conv = cl_abap_conv_in_ce=>create(

encoding = '1610'

input = l_xfeld ).

l_view = cl_abap_view_offlen=>create_unicode16_view(

g_s_packed ).

CALL METHOD lr_conv->read

EXPORTING

view = l_view

IMPORTING

data = g_s_packed.

Here the data has not converted to ASCII, its still displaying in Some different format(####)

Pls tell me what's wrong in this......

Regards,

Shake sha vali

1 REPLY 1

Former Member
0 Kudos

Hi,

For Transalation issues in Unicode you may use any of the following methoda.

We need to change all the Type X (Hexadecimal) variables to Type C with their values unchanged.

So the method to be followed is:-

1. Load the definition of the class CL_ABAP_CONV_IN_CE or CL_ABAP_CHAR_UTILITIES.

2. Declare the variable as Type C, and use the method UCCP(u2018XXXXu2019) of the class CL_ABAP_CONV_IN_CE where XXXX represents the 8-bit Hexadecimal value and incase the variable holds a Hex value for a Horizontal Tab , then the Attribute u201CHORIZONTAL_TABu201D of the class CL_ABAP_CHAR_UTILITIES can be used directly instead of using the method UCCP.

E.g.:

i) *DATA: TAB TYPE X VALUE 09, u201CTab character

CLASS: CL_ABAP_CHAR_UTILITIES DEFINITION LOAD.

DATA TAB TYPE C VALUE CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB.

ii) * DATA: CHAR TYPE X VALUE 160.

CLASS: CL_ABAP_CONV_IN_CE DEFINITION LOAD.

DATA CHAR TYPE C.

CHAR = CL_ABAP_CONV_IN_CE=>UCCP(u201800AOu2019).

(Here u201800A0u2019 is the Hexadecimal equivalent of the decimal 160).

3. Incase the TYPE X Variable has a length more than 1, then an internal table must be created for the variable.

E.g.:

CLASS: CL_ABAP_CONV_IN_CE DEFINITION LOAD.

DATA : LF(2) TYPE X VALUE 'F5CD'.

DATA : BEGIN OF LF,

A1 TYPE C,

A2 TYPE C,

END OF LF.

LF-A1 = CL_ABAP_CONV_IN_CE=>UCCP('00F5').

LF-A2 = CL_ABAP_CONV_IN_CE=>UCCP('00CD').

I4. In Case Variable is a field of Internal Table.

CLASS: CL_ABAP_CONV_IN_CE DEFINITION LOAD.

DATA:

BEGIN OF wk,

ctr TYPE i,

max TYPE i,

indent TYPE i,

staro LIKE sy-staro,

cpage LIKE sy-cpage,

ans,

repid LIKE sy-repid,

filename LIKE rlgrap-filename,

rec(80),

  • tab TYPE x VALUE '09', "V02.01KUM

tab(2) TYPE C VALUE '09', "V02.01KUM

END OF wk.

Wk-tab = CL_ABAP_CONV_IN_CE=>UCCP('0009').