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: 

Character set table for unicode conversion

Former Member
0 Kudos

Experts,

If one identifies a special character that fails during code page conversion (CX_SY_CONVERSION_CODEPAGE), can this character then be added into a table that will recongnize it and not fail moving forward? If so, how to go about it?

Any help is appreciated.

UV

1 ACCEPTED SOLUTION

former_member226999
Contributor
0 Kudos

Note this

Unicode Error : In the Unicode context, TRANSLATE... CODEPAGE/NUMBER FORMAT is not allowed.

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

Reward if helps

3 REPLIES 3

former_member226999
Contributor
0 Kudos

Note this

Unicode Error : In the Unicode context, TRANSLATE... CODEPAGE/NUMBER FORMAT is not allowed.

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

Reward if helps

0 Kudos

Thanks FY. But this still requires coding. I was thinking in terms of character set admin in transaction SPAD / SP12 or tables like TCP00. Is that possible?

This type of approach may automatically take care of 100s of programs in the system. Share your thoughts.

UV

Former Member
0 Kudos

No solution.