ABAP serch关键字

DATA STRING3(30) VALUE 'This is a little sentence.'.
WRITE: / 'Searched', 'SY-SUBRC', 'SY-FDPOS'.      "字符位置
ULINE /1(52).
SEARCH STRING3 FOR 'X'.
WRITE: / 'X', SY-SUBRC UNDER 'SY-SUBRC', "在STRING3中查找X
               SY-FDPOS UNDER 'SY-FDPOS'.

SEARCH STRING3 FOR 'itt   '.  "在STRING3中查找itt   ,itt后面的空格被忽略
WRITE: / 'itt   ', SY-SUBRC UNDER 'SY-SUBRC',
                   SY-FDPOS UNDER 'SY-FDPOS'.

SEARCH STRING3 FOR '.e .'.  "在STRING3中查找e ,e后面有一个空格
WRITE: / '.e .', SY-SUBRC UNDER 'SY-SUBRC',
                  SY-FDPOS UNDER 'SY-FDPOS'.

SEARCH STRING3 FOR '*e'. "在STRING3中查找以e结尾的单词
WRITE: / '*e ', SY-SUBRC UNDER 'SY-SUBRC',
                SY-FDPOS UNDER 'SY-FDPOS'.

SEARCH STRING3 FOR 's*'.  "在STRING3中查找以s开头的单词
WRITE: / 's* ', SY-SUBRC UNDER 'SY-SUBRC',
                SY-FDPOS UNDER 'SY-FDPOS'.

DATA F(50).
MOVE 'Alaska Texas California' TO F.
SEARCH F FOR 'Clfrn' ABBREVIATED.  "在F中搜索可以缩写为Clfrn的单词,搜索字段的第一个字母和单词的第一个字母必须匹配
WRITE: / 'Clfrn', SY-SUBRC UNDER 'SY-SUBRC',
                SY-FDPOS UNDER 'SY-FDPOS'.

MOVE 'Peter Paul Mary' TO F.
SEARCH F FOR '*UL' AND MARK.   "将查询结果转换成大写
WRITE: / '*UL', SY-SUBRC UNDER 'SY-SUBRC',
                SY-FDPOS UNDER 'SY-FDPOS'.


DATA: BEGIN OF TS OCCURS 100,
LINE(80),
END OF TS.
MOVE 'Alaska Texas ' TO TS.
APPEND TS.
MOVE 'California Arizona ' TO TS.
APPEND TS.
SEARCH TS FOR '*ONA' AND MARK.
WRITE: / 'IT *ONA', SY-SUBRC UNDER 'SY-SUBRC',
                SY-FDPOS UNDER 'SY-FDPOS'.


转载自:http://blog.csdn.net/chuzhaowei/article/details/6142577




你可能感兴趣的:(search,abap,mark,搜索单词,ABBREVIATED)