首页 > 代码库 > 20170225 ABAP获取字符串长度/字节长度
20170225 ABAP获取字符串长度/字节长度
函数YGET_CHAR_LONG:
FUNCTION YGET_CHAR_LONG. *"---------------------------------------------------------------------- *"*"本地接口: *" IMPORTING *" VALUE(STRING) TYPE STRING OPTIONAL *" EXPORTING *" VALUE(STR) TYPE STRING *" VALUE(G_LONG) TYPE I "字符串长度 *" VALUE(G_LONG_STR) TYPE I"字节长度 *"---------------------------------------------------------------------- DATA: W_UCCP TYPE I, W_TEMP(2) TYPE C, W_LEFT(100) TYPE C, W_LEN(10) TYPE C, S_LEN TYPE I . W_LEFT = STRING. DATA : BEGIN OF LINE, TEXT TYPE C, END OF LINE, ITAB LIKE TABLE OF LINE WITH HEADER LINE. *DATA str TYPE string. DO. CALL FUNCTION ‘TEXT_SPLIT‘ EXPORTING LENGTH = 2 TEXT = W_LEFT IMPORTING LINE = W_TEMP REST = W_LEFT. CALL METHOD CL_ABAP_CONV_OUT_CE=>UCCPI EXPORTING CHAR = W_TEMP RECEIVING UCCP = W_UCCP. W_LEN = STRLEN( W_TEMP ). * WRITE: /1 w_temp, * 10 w_uccp, * 25 w_len. IF W_UCCP > 256. CONCATENATE STR W_TEMP INTO STR. ENDIF. IF W_LEFT IS INITIAL OR SY-INDEX > 100. EXIT. ENDIF. ENDDO. IF STR IS NOT INITIAL. DATA:T_LEN TYPE I. CLEAR : S_LEN,G_LONG_STR. T_LEN = STRLEN( STRING ). G_LONG = STRLEN( STRING ). S_LEN = STRLEN( STR ). T_LEN = T_LEN - S_LEN . S_LEN = S_LEN * 2 . G_LONG_STR = T_LEN + S_LEN. * WRITE :/,‘CHARLEN=‘ ,charlen, ‘STR= ‘,str. ENDIF. ENDFUNCTION.
20170225 ABAP获取字符串长度/字节长度
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。