ITPub博客

首页 > Linux操作系统 > Linux操作系统 > Use class for Translate codepage to codepage.

Use class for Translate codepage to codepage.

原创 Linux操作系统 作者:fengleihen 时间:2009-06-02 21:27:08 0 删除 编辑
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

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/139677/viewspace-604934/,如需转载,请注明出处,否则将追究法律责任。

上一篇: SCP_TRANSLATE_CHARS
下一篇: email
请登录后发表评论 登录
全部评论

注册时间:2009-03-31

  • 博文量
    24
  • 访问量
    26400