截取字段的时候不要用这个语句,而是用一个SAP提供的方法CL_SCP_LINEBREAK_UTIL=>STRING_SPLIT_AT_POSITION。在Unicode环境里,所谓的双字节字符的长度计算根据登陆语言会返回不同的值。用方法"STRING_SPLIT_AT_POSITION"可以指定语言,这样就可以避免登陆语言对字符长度的影响了
report ztest2.
data:ex_pos_vis type i,
ex_pos_tech type i.
data:im_string type string value '你好会发的1134'.
call method cl_scp_linebreak_util=>string_split_at_position
exporting
im_string = im_string
im_langu = sy-langu
im_pos_vis = 100
im_pos_tech = 100
* im_boundary_kind = C_BOUNDARY_GRAPHEME
* im_metrics =
importing
ex_pos_vis = ex_pos_vis
ex_pos_tech = ex_pos_tech
exceptions
pos_not_valid = 1
unsupported_boundary_kind = 2
invalid_text_enviroment = 3
others = 4.
if sy-subrc <> 0.
message id sy-msgid type sy-msgty number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
endif.
WRITE:ex_pos_vis,ex_pos_tech.