CONV dtype|#( … )
dtype = Type you want to convert to (显式转换)
# = compiler must use the context to decide the type to convert to (隐式转换)
*简单理解
DATA: LV_TEXT TYPE CHAR01,
LV_STR TYPE STRING.
" 显式转换:将LV_TEXT转换成STRING类型
LV_STR = CONV STRING( LV_TEXT ).
" 隐式转换:将LV_TEXT转换成LV_STR的类型
LV_STR = CONV #( LV_TEXT ).
"before
DATA text TYPE c LENGTH 255.
DATA helper TYPE string.
DATA xstr TYPE xstring.
helper = text.
xstr = cl_abap_codepage=>convert_to( source = helper ).
"740
DATA text TYPE c LENGTH 255.
DATA(xstr) = cl_abap_codepage=>convert_to( source = CONV string( text ) ).
OR
DATA(xstr) = cl_abap_codepage=>convert_to( source = CONV #( text ) ).
matinal:SAP ABAP7.40及以上新语法-CONV 运算符
最新推荐文章于 2024-06-18 20:58:25 发布
本文介绍了ABAP编程中LV_TEXT和STRING类型之间的转换,区分了显式转换LV_TEXT->STRING和编译器决定的隐式转换LV_TEXT->LV_STR的过程,以及使用cl_abap_codepage进行编码转换的例子。
1414

被折叠的 条评论
为什么被折叠?



