*******字符串控制函数********
CONCATENATE:实现字符串合并
语法:CONCATENATE F1...FN INTO G <SEPARATED BY H>
DATA: ONE(10) VALUE 'HELLO',
TWO(10) VALUE 'SAP',
RESULT1(10),
RESULT2(10).
CONCATENATE ONE TWO INTO RESULT1 SEPARATED BY SPACE.
CONCATENATE ONE TWO INTO RESULT2.
CONCATENATE ONE TWO INTO ONE.
CONCATENATE ONE TWO INTO TWO.

SPLIT:实现字符串的拆分
语法1:SPLIT F AT G INTO H1...HN
语法2:SPLIT F AT G INTO TABLE ITAB
DATA: NAMES(30) TYPE C VALUE 'HELLO,SAP',
NAMES2 TYPE STRING,
ONE(10) TYPE C,
TWO(10) TYPE C,
DELIMITER(1) VALUE ','.
TYPES: BEGIN OF ITAB_TYPE,
WORD(20),
END OF ITAB_TYPE.
DATA: ITAB TYPE STANDARD TABLE OF ITAB_TYPE WITH HEADER LINE.

SPLIT NAMES AT DELIMITER INTO ONE TWO.
SPLIT 'ONE STOP TWO STOP THREE STOP' AT 'STOP' INTO TABLE ITAB.
WRITE: ONE.

SHIFT:将字符串整体或者子串进行转移
语法1:SHIFT C <LEFT/RIGHT/CIRCULAR>
语法2:SHIFT C <LEFT/RIGHT/CIRCULAR> BY N PLACES
语法3:SHIFT C <LEFT/RIGHT/CIRCULAR> UP TO C1
语法4:SHIFT C LEFT DELETING LEADING C1
语法5:SHIFT C RIGHT DELETING LEADING C1
DATA: STR1(15) TYPE C VALUE ' ABCDEFGHIJ',
STR2(15) TYPE C,
STR3(15) TYPE C,
STR4(15) TYPE C,
STR5(15) TYPE C,
STR6(15) TYPE C,
THREE(3) TYPE C VALUE 'DEF',
FOUR(3) TYPE C VALUE 'DEF',
M1(4) VALUE 'ABCD',
M2(6) VALUE 'HIJ'.
STR6 = STR5 = STR4 = STR3 = STR2 = STR1.
SHIFT STR1.
SHIFT STR2 CIRCULAR UP TO THREE.
SHIFT STR3 RIGHT.
SHIFT STR4 CIRCULAR.
SHIFT STR5 BY 5 PLACES.
SHIFT STR6 CIRCULAR BY 2 PLACES.
SHIFT STR1 LEFT DELETING LEADING SPACE.
SHIFT STR1 RIGHT DELETING TRAILING M2.
IF STR1 EQ 'ABCDEFG'.
WRITE: 'EQ'.
ENDIF.

CONDENSE:重新整合分配字符串
语法:CONDENSE C <NO-GAPS>.
DATA: NAME(40).
NAME(10) = ' DR.'.
NAME+10(10) = 'MICHAEL'.
NAME+20(10) = 'HOFMANN'.
CONDENSE NAME.
IF NAME EQ 'DR.MICHAEL HOFMANN'.
WRITE NAME.
ENDIF.

TRANSLATE:实现字符串转换
语法1:TRANSLATE C TO UPPER CASE.
语法2:TRANSLATE C TO LOWER CASE.
语法3:TRANSLATE C USING C1
语法4:TRANSLATE C FORM CODE PAGE G1...TO CODE PAGE G2.
DATA: STR1(3) TYPE C VALUE 'ABC',
STR2(4) TYPE C VALUE 'EFGH'.
DATA: STR(20) TYPE C VALUE 'ABCABCABCXABCF',
CHANGE(15) TYPE C VALUE 'AXBAYBABZACZB'.
TRANSLATE STR USING CHANGE.将STR的字符和CHANGE字符逐一比较,
如果找到CHANGE中某个字符与之相等则用CHANGE中该字符后面的字符进行替换它
TRANSLATE STR1 TO UPPER CASE.
TRANSLATE STR2 TO LOWER CASE.

OVERLAY:参考字符串对空白字符进行填充
语法:OVERLAY C1 WITH C2.
DATA: WORK(20) VALUE 'TH T H S CH NG D',
HELP(20) VALUE 'GRAB A PATTERN'.
OVERLAY WORK WITH HELP.
*执行结果:WORK = 'THAT HAS CHANGED'

REPLACE:字符串按条件取代
语法:REPLACE F WITH G INTO H.
DATA: STR(10) VALUE '12345ABCDE'.
REPLACE '12345' WITH '56789' INTO STR.
WRITE: ''.