ASCII和字母的转换

*** 字母到对应的ASCII码
DATA : c.
FIELD-SYMBOLS : <n> TYPE x.
DATA : rn TYPE i.
c = ‘A’.
ASSIGN c TO <n> CASTING.
MOVE <n> TO rn.
WRITE rn.
 
*** ASCII到字母
DATA : i TYPE i VALUE 66.
DATA : x TYPE x.
FIELD-SYMBOLS : <fc> TYPEc.
MOVE i TO x.
ASSIGN x TO <fc> CASTING TYPEc.
MOVE <fc> TO c.
WRITE c.
 
 
ECC6
———————————————-
DATA: str TYPE string ,
          xstr TYPE xstring,
          l_con TYPE REF TO cl_rpe_convert .
 
START-OF-SELECTION.
  CREATE OBJECT l_con.
  CALL METHODl_con->string_to_xstring
      EXPORTING
          input  = ‘ABC’
      IMPORTING
          output = xstr.
  CALL METHODl_con->xstring_to_string
      EXPORTING
          input  = ‘4261727279′
      IMPORTING
          output = str.
  WRITE / :  xstr ,str.

你可能感兴趣的:(ASCII和字母的转换)