Chinaunix首页 | 论坛 | 博客
  • 博客访问: 224903
  • 博文数量: 23
  • 博客积分: 1400
  • 博客等级: 上尉
  • 技术积分: 311
  • 用 户 组: 普通用户
  • 注册时间: 2008-03-29 20:09
文章分类

全部博文(23)

文章存档

2009年(5)

2008年(18)

我的朋友

分类:

2008-03-31 23:31:43

ECC5 help:Byte und ZeichenkettenveRARBEITUNG\PROCESSING character strings
例子参考ABAPdocu
函数查询:
(帮助)
ABAP - The SAP Programming Language\
ABAP - By Theme\
Process Internal Data\Byte String and Character String Processing
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等等.
CL_ABAP_CHAR_UTILITIES=>BYTE_ORDER_MARK_LITTLE-----(utf-16le')的文件头
CL_ABAP_CHAR_UTILITIES=>BYTE_ORDER_MARK_UTF8-------(utf-8)的文件头
例如:转unicode的时候:
*  W_TYPE = 'APPLICATION/MSEXCEL;charset=utf-16le'.
  W_TYPE = 'APPLICATION/MSEXCEL;charset=utf-8'.
*  W_TYPE = '  =utf8'.
  CALL FUNCTION 'SCMS_STRING_TO_XSTRING'
    EXPORTING
      TEXT     = L_STRING
      MIMETYPE = W_TYPE
    IMPORTING
      BUFFER   = L_XSTRING
    EXCEPTIONS
      FAILED   = 1
      OTHERS   = 2.
  IF SY-SUBRC EQ 0.
*    CONCATENATE CL_ABAP_CHAR_UTILITIES=>BYTE_ORDER_MARK_LITTLE(utf-16le')的文件头
    CONCATENATE CL_ABAP_CHAR_UTILITIES=>BYTE_ORDER_MARK_UTF8(utf-8)的文件头....
  endif.
-------------------------------------------------
是否全是数字
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
------------------------------------------------------------
(站长注:本文内容不完整 未分类 欢迎提供建议 争取达到 方便快速查阅的效果,免得写代码的时候被字符操作这样的小问题耽误时间)
 
 
 
 
阅读(6076) | 评论(0) | 转发(0) |
0

上一篇:BSP下载CSV文件

下一篇:版权声明

给主人留下些什么吧!~~