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: 

Unicode

Former Member
0 Kudos
86

The following statement:

TRASLATE XYZ FROM CODE-PAGE '1110' TO CODE-PAGE '0100'.

fails in a Unicode Scenario.

However, there are Class Utilities available for the same function but I do not

understand how to use them and which ones are used for which translations.

1110 seems to be hp-ascii

0100 seems to be ibm-ebcdic

Could anyone tell me what will be the acceptable copunterpart in a Unicode System.

1 ACCEPTED SOLUTION

Former Member
0 Kudos
45

Hi mansi,

may be it will help full check it out.

Before Unicode

TRANSLATE T143T-TBTXT FROM CODE PAGE '1100' TO CODE PAGE '1105'.

After Unicode

Use class for Translate codepage to codepage.

Data : g_codepage LIKE tcp0c-charco VALUE '1100'.

CONSTANTS: c_unicodecp(4) VALUE '1105'.

PERFORM translate_codepage USING g_codepage

c_unicodecp

CHANGING T143T.

FORM translate_codepage USING P_G_CODEPAGE

P_C_UNICODECP

CHANGING P_T143T.

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 = P_G_CODEPAGE.

l_tocode = P_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 <> 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 = P_T143T

inbufflg = 0

outbufflg = 0

IMPORTING

outbuff = l_out

EXCEPTIONS

internal_error = 1

OTHERS = 2.

IF sy-subrc <> 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.

P_T143T = l_out.

ENDFORM. " translate_codepage

Referred

3 REPLIES 3

Former Member
0 Kudos
45

Hi,

Plz refer this

TRANSLATE ... CODEPAGE ...

TRANSLATE ... NUMBER FORMAT ...

The above statements are not allowed in Unicode programs. Instead, you can use the new conversion classes, which are described in more detail in Converting Data.

http://help.sap.com/saphelp_47x200/helpdata/en/79/c554afb3dc11d5993800508b6b8b11/frameset.htm

Former Member
0 Kudos
46

Hi mansi,

may be it will help full check it out.

Before Unicode

TRANSLATE T143T-TBTXT FROM CODE PAGE '1100' TO CODE PAGE '1105'.

After Unicode

Use class for Translate codepage to codepage.

Data : g_codepage LIKE tcp0c-charco VALUE '1100'.

CONSTANTS: c_unicodecp(4) VALUE '1105'.

PERFORM translate_codepage USING g_codepage

c_unicodecp

CHANGING T143T.

FORM translate_codepage USING P_G_CODEPAGE

P_C_UNICODECP

CHANGING P_T143T.

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 = P_G_CODEPAGE.

l_tocode = P_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 <> 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 = P_T143T

inbufflg = 0

outbufflg = 0

IMPORTING

outbuff = l_out

EXCEPTIONS

internal_error = 1

OTHERS = 2.

IF sy-subrc <> 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.

P_T143T = l_out.

ENDFORM. " translate_codepage

Referred

0 Kudos
45

Thanks Praveen.

Chaitanya's post that you have referred in your post was very helpful.

However, I am still getting an error because the structure that i'm trying to pass to the subroutine in the example has variables of mixed data types.

Is it that I have to call the subroutine for individual structure items???

Regards,

Priya

Edited by: Priya Swaminathan on Feb 8, 2008 2:49 PM