其他分享
首页 > 其他分享> > ABAP字符串处理方法

ABAP字符串处理方法

作者:互联网

*&---------------------------------------------------------------------*
*& Report  Z7
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*

REPORT Z7.

DATA str TYPE string.

str = 'java+mysql+springMVC+mybatis+spring'.
WRITE str.

ULINE.

*将mysql替换成mssql
REPLACE 'mysql' WITH 'mssql' INTO str.
WRITE str.

ULINE.

*字符串搜索
SEARCH str for 'mybatis'.
WRITE:/ sy-subrc.  "是否存在,如果0 则说明找到
WRITE:/ sy-fdpos.  "mybatis在字符串出现的位置


*字符串长度
DATA len type i.
len = STRLEN( str ).
WRITE: / '字符串长度:' , len.


*字符串拼接
DATA cmdText1 type string.
DATA cmdText2 type string.
DATA cmdText3 type string.
DATA cmdText type string.

cmdText1 = 'INSERT INTO user('.
cmdText2 = 'name,age) VALUES('.
cmdText3 = '"liush",32)'.

WRITE /.

CONCATENATE cmdText1 cmdText2 cmdText3 INTO cmdText.
WRITE cmdText.

ULINE.


*分割字符
DATA idstr TYPE string.
DATA text1 like idstr.
DATA text2 like idstr.

idstr = '10,11,30,70'.
WRITE idstr.

SPLIT idstr AT ',' INTO text1 text2.

WRITE: / 'text1=', text1.
WRITE: / 'text2=', text2.

ULINE.

*全部转换大写
TRANSLATE cmdText TO UPPER CASE.
WRITE cmdText.

ULINE.

*全部转为小写
TRANSLATE cmdText TO LOWER CASE.
WRITE cmdText.

 

标签:cmdText,string,处理,idstr,WRITE,ABAP,str,字符串,DATA
来源: https://www.cnblogs.com/hua900822/p/16526979.html