ABAP CDS - 字符串函数
下表显示了ABAP CDS中CDS视图中字符串的潜在SQL函数,以及对参数的要求。函数的含义可以在字符串的SQL函数下找到。
| 函数 | 参数类型 | 返回类型 |
| CONCAT(arg1, arg2) | See below | SSTRING if an argument has the type SSTRING, else CHAR with the length of the result. |
| CONCAT_WITH_SPACE(arg1, arg2, spaces ) | arg1, arg2: see below
spaces: positive numeric literal greater than 0 and less than or equal to 1331 |
SSTRING if an argument has the type SSTRING, else CHAR with the length of the result. |
| INSTR(arg, sub) | arg: see below
sub: non-empty numeric literal |
INT4 |
| LEFT(arg, len) | arg: see below
len: positive numeric literal greater than 0 and less than or equal to 1333 |
SSTRING if arg has the type SSTRING, else CHAR with length len |
| LENGTH(arg) | See below | INT4 |
| LPAD(arg, len, src) | arg: see below
len: positive numeric literal greater than 0 and less than or equal to 1333 src: character Literal |
SSTRING if arg has the type SSTRING, else CHAR with length len |
| LTRIM(arg, char) | arg: see below
char: Character literal with length 1 |
SSTRING if arg has the type SSTRING, else CHAR with the length of arg. |
| REPLACE(arg1, arg2, arg3) | See below | SSTRING if arg1 or arg3 has the type SSTRING, else CHAR with the maximum possible length of the result. |
| RIGHT(arg,len) | arg: see below
len: positive numeric literal greater than 0 and less than or equal to 1333 |
SSTRING if arg has the type SSTRING, else CHAR with length len |
| RPAD(arg, len, src) | arg: see below
len: positive numeric literal greater than 0 and less than or equal to 1333 src: character literal |
SSTRING if arg has the type SSTRING, else CHAR with length len |
| RTRIM(arg, char) | arg: see below
char: Character literal with length 1 |
SSTRING if arg has the type SSTRING, else CHAR with the length of arg. |
| SUBSTRING(arg, pos, len) | arg: see below
pos and len: positive numeric literal not equal to zero |
SSTRING, if arg has the type SSTRING, else CHAR or NUMC with a length of at least len |
以下可以指定为参数:
- suitable类型的文字。文本可以以域名作为前缀。
- 当前CDS视图的数据源数据源的适当字段。
- 用于标识数据源数据源的适当字段的路径表达式。
- 以下预定义的函数和表达式(如果它们返回匹配的类型):
- 其他预定义的SQL函数
- 算术表达式
- Type modifications using CAST
arg、arg1、arg2和arg3的有效参数类型为char、clnt、lang、numc、cuky、unit、dats、tims和sstring。
在指定了显式长度len的函数中,当CDS视图被激活时,结果的实际长度被定义为至少和len一样长。
在除lpad和rpad之外的所有函数中,所有参数的尾随空格在实际处理之前被删除,结果的尾随空格在返回操作之前被删除。在lpad和rpad中,参数src的尾随空格被保留。
注释
系统代码页utf-16的代理区域中的字符由cds字符串函数作为两个字符处理。在确定长度时必须遵守这一点,并且这些字符不能被错误地拆分。
例子
以下CDS视图将选择列表中字符串的预定义SQL函数应用于数据库表demo_表达式的列。程序演示光盘的SQL函数字符串使用select访问视图。
-
@AbapCatalog.sqlViewName: 'DEMO_CDS_STRFUNC'
@AccessControl.authorizationCheck: #NOT_REQUIRED
define view demo_cds_sql_functions_string
as select from demo_expressions
{ length( char1 ) as r_length,
instr( char1, 'CD' ) as r_instr,
concat( char1, char2 ) as r_concat,
concat_with_space( char1, char2, 10 ) as r_concat_with_space,
left( char1, 3 ) as r_left,
right( char2, 3 ) as r_right,
lpad( char1, 10, 'x' ) as r_lpad,
rpad( char2, 10, 'y' ) as r_rpad,
ltrim( char1, 'A' ) as r_ltrim,
rtrim( char1, 'E' ) as r_rtrim,
replace( char2, 'GHI', 'XXX' ) as r_replace,
substring( char2, 2, 3 ) as r_substring }
SQL函数的字符串
下表显示了abap cds和open sql支持的字符串的SQL函数。最后两列指示函数的使用位置。
| SQL 函数 | 结果 | ABAP CDS | Open SQL |
| CONCAT(arg1, arg2) | Chaining of character strings in arg1 and arg2. Trailing blanks in arg1, arg2, and in the result are ignored. The maximum length of the result is 1333. | x | x |
| CONCAT_WITH_SPACE(arg1, arg2, spaces ) | Concatenation of strings in arg1 and arg2 as with CONCAT. The number of blanks specified in spaces is inserted between arg1 and arg2. The maximum length of the result is 1333. | x | - |
| INSTR(arg, sub) | Position of the first occurrence of the string from sub in arg (case-sensitive). arg respects leading blanks and ignores trailing blanks. sub respects all blanks. sub must contain at least one character. If no occurrences are found, the result is 0. | x | - |
| LEFT(arg, len) | String of the length len with the len left characters of arg (ignoring the trailing blanks). The value of len cannot be greater than the length of arg. | x | - |
| LENGTH(arg) | Number of characters in arg ignoring trailing blanks. | x | x |
| LPAD(arg, len, src) | String of the length len with the right-justified content of arg without trailing blanks and in which leading blanks produced by the expanded string are replaced by the characters from the argument src (respecting all blanks). Trailing blanks from arg are preserved. If more characters are required than exist in src, the content of src is used repeatedly. If len is less than the length of arg, it is truncated on the right. If src is empty and len is greater than the length of arg, arg remains unchanged. | x | x |
| LTRIM(arg, char) | String with the content of arg in which all trailing blanks are removed and all leading characters that match the character in char. A blank in char is significant. | x | x |
| REPLACE(arg1, arg2, arg3) | Character string arg1, in which all instances of arg2 are replaced by the content from arg3. The replacement of letters is case-sensitive. Trailing blanks are ignored in all arguments. The maximum length of the result is 1333. | x | x |
| RIGHT( arg, len ) | String of the length len with the len right characters of arg (ignoring the trailing blanks). The value of len cannot be greater than the length of arg. | x | x |
| RPAD(arg, len, src) | String of the length len with the left-justified content of arg without trailing blanks and in which trailing blanks produced by the expanded string are replaced by the characters from the argument src (respecting all blanks). Trailing blanks from arg are preserved. If more characters are required than exist in src, the content of src is used repeatedly. If len is less than the length of arg, it is truncated on the right. If src is empty and len is greater than the length of arg, arg remains unchanged. | x | - |
| RTRIM(arg, char) | String with the content of arg in which all trailing blanks are removed and all trailing characters that match the character in char. A blank in char is significant. | x | x |
| SUBSTRING(arg, pos, len) | Substring of arg from the position pos in the length len. pos and len must be specified so that the substring is within in arg. |
关于潜在操作数和数据类型的描述可以在ABAPCDS和OpenSQL的相应文档中找到。
参考文章
本文原始地址:https://www.cnblogs.com/yjyongil/p/10495142.html
ABAP CDS - 字符串函数的更多相关文章
- 【ABAP CDS系列】ABAP CDS中的系统信息
公众号:SAP Technical 本文作者:matinal 原文出处:http://www.cnblogs.com/SAPmatinal/ 原文链接:[ABAP CDS系列]ABAP CDS中的系统 ...
- ABAP CDS Table Function介绍与示例
Core data services(以下简称CDS)可以指两样东西,一个是HANA CDS,一个是ABAP CDS. 如我们所知,HANA CDS只支持HANA数据库,ABAP CDS理论上支持多种 ...
- ABAP发邮件函数
步骤: 一.检查输入参数, (1)未指定文件類別代碼,(2)未指定郵件主題, (3)未指定郵件內容, (4)未指定發送人郵件地址, (5)未指定接收人郵件地址, 二.调用发送功能, (1)创建发送请求 ...
- ABAP CDS-介绍(ABAP CDS视图)
前言 文章翻译自Tushar Sharma的文章,转载请注明原作者和译者! 在SAP发展到SAP HANA版本之后,SAP内部的技术正在快速地变化,SAP开发业务应用程序的方式已经发生了范式转变(根本 ...
- ABAP CDS-Part 1(ABAP CDS实体)
文章翻译自Tushar Sharma的文章,转载请注明原作者和译者! 目录 预备条件 一.概述 二.ABAP CDS实体(CDS Entity) a.定义ABAP CDS Views b.ABAP C ...
- ThinkPHP 模板substr的截取字符串函数
ThinkPHP 模板substr的截取字符串函数在Common/function.php加上以下代码 /** ** 截取中文字符串 **/ function msubstr($str, $start ...
- SQL字符串函数
LEN() :计算字符串长度(字符的个数.)datalength();//计算字符串所占用的字节数,不属于字符串函数.测试varchar变量与nvarchar变量存储字符串a的区别.见备注1.LOWE ...
- Python3中的字符串函数学习总结
这篇文章主要介绍了Python3中的字符串函数学习总结,本文讲解了格式化类方法.查找 & 替换类方法.拆分 & 组合类方法等内容,需要的朋友可以参考下. Sequence Types ...
- TSQL 字符串函数:截断和查找
字符串截断函数是指:Stuff 和 SubString,字符串查找函数是:CharIndex 和 PatIndex 一,SubString 截取子串 最常用的字符串函数,用于截取特定长度的子串. SU ...
随机推荐
- 为我们的SSR程序添加热更新功能
前沿 通过上一篇文章 通过vue-cli3构建一个SSR应用程序 我们知道了什么是SSR,以及如何通过vue-cli3构建一个SSR应用程序.但是最后遗留了一些问题没有处理,就是没有添加开发时的热更新 ...
- 使用TimeSpan对象获取时间间隔
实现效果: 关键知识: TimeSpan对象表是时间间隔或持续时间,两个DateTime对象相减,则会得到一个TimeSpan对象 使用其days ,hours,minutes等属性 实现代码: pr ...
- 【转】同步的HttpClient使用详解
http://blog.csdn.net/angjunqiang/article/details/54340398 背景 服务端以及客户端在开发过程中不可避免的会使用到网络请求,网络请求可以使用Jav ...
- 【洛谷P4342】[IOI1998]Polygon
Polygon 比较裸的环形DP(也可以说是区间DP) 将环拆成链,复制到后面,做区间DP即可 #include<iostream> #include<cstdio> usin ...
- 【luogu P2455 [SDOI2006]线性方程组】 题解
题目链接:https://www.luogu.org/problemnew/show/P2455 无解:最后一列对应元素不为0,前面全是0. 无穷解:一行全是0. 嗯...在消元过程中不要直接拿矩阵元 ...
- 学大伟业 Day 5 培训总结
今天讲数据结构 先从mzx大佬的ppt摘抄一段: 数据结构是计算机存储.组织数据的方式.数据结构是指相互之间存在一种或多种特定关系的数据元素的集合. 通常情况下,精心选择的数据结构可以带来更高的运行或 ...
- HTML5之canvas基本API介绍及应用 1
一.canvas的API: 1.颜色.样式和阴影: 2.线条样式属性和方法: 3.路径方法: 4.转换方法: 5.文本属性和方法: 6.像素操作方法和属性: 7.其他: drawImage:向画布上绘 ...
- An error occurred during the installation of assembly 'Microsoft.VC90.ATL or 'Microsoft.VC80.ATL'
An error occurred during the installation of assembly 'Microsoft.VC90.ATL or 'Microsoft.VC80.ATL' 下载 ...
- Java并发编程:线程封闭和ThreadLocal详解
转载请标明出处: http://blog.csdn.net/forezp/article/details/77620769 本文出自方志朋的博客 什么是线程封闭 当访问共享变量时,往往需要加锁来保证数 ...
- 有连接服务&无连接服务
面向连接的服务 通信双方在通信时要事先建立一条通信线路,其过程包括建立连接.使用链接.释放链接三个过程 如: TCP 电话 面向无连接的服务 通信双方不需要事先建立一条通信线路,而是把每个带有目的选址 ...