在编写SAP程序时,程序员经常需要将常字符串进行分割,在字符串中加入回车换行或TAB字符,在其他语言可以使用$13$10的ASCII码进行插入.而在abap里却出错,为了解决此问题,请使用sap的类CL_ABAP_CHAR_UTILITIES.
CL_ABAP_CHAR_UTILITIES中有字符常量:如:CR_LF,HORIZONTAL_TAB,NEWLINE等等.
下面给出字符串中加入回车换行的示例:
CL_ABAP_CHAR_UTILITIES中有字符常量:如:CR_LF,HORIZONTAL_TAB,NEWLINE等等.
下面给出字符串中加入回车换行的示例:
DATA: crlf(2) TYPE c.
DATA: l_html(4096) TYPE C.
crlf = cl_ABAP_char_utilities=>cr_lf.
CONCATENATE l_html crlf '_FUNCTION'
'30'
'WWW_GET_REPORT' '>' INTO l_html.
string的标准函数
查找: FIND [{FIRST OCCURRENCE}|{ALL OCCURRENCES} OF] pattern IN dobj
替换: REPLACE [{FIRST OCCURRENCE}|{ALL OCCURRENCES} OF] pattern IN dobj WITH new
REPLACE SECTION [OFFSET off] [LENGTH len] OF dobj WITH new
移动:SHIFT c [BY n PLACES] [mode]
拼接:CONCATENATE c1 ... cn INTO c [SEPARATED BY s]
分割:SPLIT c AT del INTO c1 ... cn.
大小写转换:TRANSLATE text TO UPPER CASE.
TRANSLATE text TO LOWER CASE.
字符串覆盖:OVERLAY c1 WITH c2 [ONLY str].
压缩字符串:CONDENSE c [NO-GAPS].
系统扩张的string函数(函数组CSTR)
STRING_LENGTH
STRING_CONCATENATE
STRING_MOVE_RIGHT
STRING_REVERSE
STRING_SPLIT
STRING_CENTER
TEXT_SPLIT
STRING_SPLIT_AT_POSITION
OVERLAY_BYTE
SJIS_SBC_TO_DBC
SJIS_DBC_TO_SBC
STRING_CONCATENATE
STRING_MOVE_RIGHT
STRING_REVERSE
STRING_SPLIT
STRING_CENTER
TEXT_SPLIT
STRING_SPLIT_AT_POSITION
OVERLAY_BYTE
SJIS_SBC_TO_DBC
SJIS_DBC_TO_SBC