介绍两个abap中全角半角转换的函数,这两个函数在对日开发中会经常用到,用来转换全角半角的日文平假名,片假名:
1) SJIS_DBC_TO_SBC : 全角转半角
2) SJIS_SBC_TO_DBC : 半角转全角
完整代码:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
REPORT ztest_sjis. DATA:l_text TYPE c LENGTH 255. l_text = '123qwe 456,.'. * 半角转全角 CALL FUNCTION 'SJIS_SBC_TO_DBC' EXPORTING all = 'X' * KATAKANA = ' ' * ALPHABET_UPPER = ' ' * ALPHABET_LOWER = ' ' * NUMERIC = ' ' * SPECIAL = ' ' * SPACE_CONVERSION = ABAP_FALSE * IMPORTING * CONVERTED = * HIT = CHANGING text = l_text * EXCEPTIONS * OVERFLOW = 1 * OTHERS = 2 . IF sy-subrc = 0. WRITE:/ '全角' , l_text. ENDIF. * 全角转半角 CALL FUNCTION 'SJIS_DBC_TO_SBC' EXPORTING all = 'X' * KATAKANA = ' ' * KATAKANA_LOOSE = ' ' * ALPHABET_UPPER = ' ' * ALPHABET_LOWER = ' ' * NUMERIC = ' ' * SPECIAL = ' ' * IMPORTING * CONVERTED = CHANGING text = l_text * EXCEPTIONS * OVERFLOW = 1 * OTHERS = 2 . IF sy-subrc = 0. WRITE:/ '半角' , l_text. ENDIF. |
运行结果:
以上。
发表评论