REPORT Y0825_DATA_OPERATION.
*字符串数据处理
DATA STR TYPE C LENGTH 10 VALUE 'ABCDEFGHIJ'.
WRITE: / '原 来 的:',STR.
SHIFT STR BY 2 PLACES RIGHT.
WRITE: / '后 来 的:',STR.
SHIFT STR BY 2 PLACES LEFT.
WRITE: / '再后来的:',STR.
*取代字符串内容
DATA STR1 TYPE C LENGTH 3 VALUE 'DEF'.
REPLACE STR1 WITH '123' INTO STR.
WRITE: / '取 代 后:',STR.
*大小写转换
*TRANSLATE STR TO UPPER CASE. "大写
TRANSLATE STR TO LOWER CASE.
WRITE: / '转小写后:',STR.
*在字符串中寻找部分字符串
SEARCH 'abc' FOR STR.
WRITE: / SY-SUBRC,SY-FDPOS.
*字符串长度
DATA LEN TYPE I.
LEN = STRLEN('QWER').
WRITE: / '字符串 ‘QWER’的长度',LEN.
*取部分字符串
DATA T TYPE C LENGTH 10 VALUE 'ABCEDFGHIJ'.
WRITE: / '字符串ABCEDFGHIJ中取 +2(4):',T+2(4).
*组合字符串的函数
DATA: ST1 TYPE C LENGTH 4,
ST2 TYPE C LENGTH 4,
ST3 TYPE C LENGTH 8.
ST1 = '2014'.
ST2 = '0806'.
CONCATENATE ST1 ST2 INTO ST3.
WRITE:/ '字符串2014与0806组合成:',ST3.
*去掉字符串中间的空格
DATA S TYPE C LENGTH 10.
S = ' ABC DEF '.
CONDENSE S NO-GAPS.
WRITE:/ '字符串'' ABC DEF ''去空格:',S.