您的位置:首页 > 其它

ABAP字符串常用操作

2008-05-27 23:15 316 查看
CONCATENATE 连接字符串 [SEPARATED BY 分割符]
find

SPLIT 拆分子串
------------------------------------------------------
取前八位
data a type c(30).
a = '88888888abcdefg'.
a = a(6). "取前6位
a = a+6(1). "取第7位
a = a+6 . "取第六位后的所有字符
-------------------------------------------------------
拆分
split XXX at into table XXX
SPLIT dobj AT sep INTO
{ {result1 result2 ...} | {TABLE result_tab} }
[IN {BYTE|CHARACTER} MODE].
--------------------------------------------------------
拼接
DATA NAME (30).
NAME(10) = ' Dr.',
NAME+10(10) = 'Michael',
NAME+20(10) = 'Hofmann'.
CONDENSE NAME.
WRITE NAME.
-------------------------------------------------------
去空格
CONDENSE
-------------------------------------------------------
查找
Search for all occurrences of the string "now" in a string literal using a WHILE loop. After every successful search, the search range is redefined to start after the found location. This enables you to find all occurrences of the search string even in releases before 7.0.
DATA: patt TYPE string VALUE `now`,
text TYPE string,
off TYPE i,
moff TYPE i,
mlen TYPE i.
off = 0.
WHILE sy-subrc = 0.
FIND patt IN SECTION OFFSET off OF
`Everybody knows this is nowhere`
MATCH OFFSET moff
MATCH LENGTH mlen.
IF sy-subrc = 0.
WRITE / moff.
off = moff + mlen.
ENDIF.
ENDWHILE.
------------------------------------------------------------
补零
数字前补零
用途:
在查语句中,'00006' 和 '6' 是不同的字符,
而SAP会自动将查询条件变量前面的零去掉。导致查询条件不正确,
这时候要用CONVERSION_EXIT_ALPHA_INPUT进行补零。
注意:变量类型要与数据库字段类型一直,否则补零的位数不正确。
------------------------------------------------------------
字符串长度
strlen( char_var )
------------------------------------------------------------
回车符
A Virtual Characterstic is a normal Characterstic,The Only difference is the data will be Updated at the time of Query Execution.Just Create a Characterstic add this Char to the Cube.You need to write some ABAP Code to Update this Char.
You will find the Doumentation and Example in SMOD for Virtual Characterstics and Keyfigures.
for Documentation and Example.
Goto Tcode SMOD -> Enter Enhancement as RSR00002 ,Select the Radio button Documentation -> Click on Display
用sap的类CL_ABAP_CHAR_UTILITIES( TYPE-POOLS: abap.).
CL_ABAP_CHAR_UTILITIES中有字符常量:如:CR_LF,HORIZONTAL_TAB,NEWLINE等等.
-------------------------------------------------
是否全是数字
if aaa CO '01234567888889 '.
---------------------------------------------------
数学函数
ABAP 代码编辑器中 strlen F1。
ABAP - Keyword documentation
ABAP By Theme
Built-in Type, Data Objects, and Functions
Built-in Functions
Mathematical Functions
------------------------------------------------------------
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: