1.字符转ASCII
URL_ASCII_CODE_GET
特点:根据这个算法可以中文转ASCII
DATA: char_cd(2) TYPE c.
CALL FUNCTION 'URL_ASCII_CODE_GET'
EXPORTING
trans_char = 'A'
IMPORTING
char_code = char_cd.
WRITE /: char_cd.
2. 利用cl_rpe_convert字符与ASCII互转
DATA: str TYPE string ,
xstr TYPE xstring,
l_con TYPE REF TO cl_rpe_convert .
START-OF-SELECTION.
CREATE OBJECT l_con.
CALL METHOD l_con->string_to_xstring
EXPORTING
input = 'ABC'
IMPORTING
output = xstr.
CALL METHOD l_con->xstring_to_string
EXPORTING
input = '426172727942'
IMPORTING
output = str.
WRITE / : xstr ,str.
3. 特殊字符处理 利用类CL_ABAP_CHAR_UTILITIES在字符串中加入tab字符,回车换行符,换页符
DATA: str TYPE string ,
xstr TYPE xstring,
l_con TYPE REF TO cl_rpe_convert .
START-OF-SELECTION.
CREATE OBJECT l_con.
str = cl_abap_char_utilities=>cr_lf.
CALL METHOD l_con->string_to_xstring
EXPORTING
input = str
IMPORTING
output = xstr.
CALL METHOD l_con->xstring_to_string
EXPORTING
input = '4213'
IMPORTING
output = str.
WRITE / : xstr ,str.
引用自:http://www.cnblogs.com/walter_wang/archive/2009/02/05/1384630.html