The following table shows the relational operators for comparisons between character-like operands (single data objects or return values or string expressions) in comparison expressions.

The trailing blanks are respected for operands of type string. If not stated differently in the following table, the trailing blanks are ignored for operands of types c, d, n, and t.

operator Meaning
CO Contains Only: True, if operand1 only contains characters from operand2. It is case-sensitive and trailing blanks are respected in both operands. If operand2 is of type string and initial, then the relational expression is false, except if operand1 is also of type string and initial. If operand1 has the type string and is initial, the relational expression is always true, regardless of operand2. If the comparison is true, sy-fdpos contains the offset of the first character in operand1 that is not contained in operand2. If the comparison is true, sy-fdpos contains the length of operand1.
CN Contains Not Only: True if a relational expression with CO is false, that is, if operand1 contains not only characters from operand2. sy-fdpos is set in the same way as for CO. If the comparison is true, sy-fdpos contains the offset of the first character in operand1 that is not contained in operand2. If the comparison is false, sy-fdpos contains the length of operand1.
CA Contains Any: True, if operand1 contains at least one character from operand2. It is case-sensitive and trailing blanks are respected in both operands. If operand1 or operand2 are of the type string and initial, the relational expression is always false. If result of the comparison is positive, sy-fdpos contains the offset of the first character in operand1 that is also contained in operand2. If the comparison is false, sy-fdpos contains the length of operand1.
NA Contains Not Any: True, if a relational expression with CA is false, that is if operand1 does not contain any characters from operand2. If the comparison is false, sy-fdpos contains the offset of the first character in operand1 that is also contained in operand2. If the comparison is true, sy-fdpos contains the length of operand1.
CS Contains String: True, if the content of operand2 is contained in operand1. It is not case-sensitive and trailing blanks in the left operand are respected. If operand1 is of type string and initial, or of type c and contains only blank characters, the relational expression is false, unless operand2 is also of type string and initial, or of type c and only contains blank characters. In this case, the relational expression is always true. If the comparison is true, sy-fdpos contains the offset of operand2 in operand1. If the comparison is false, sy-fdpos contains the length of operand1.
NS Contains No String: True, if a relational expression with CS is false, that is if operand1 does not contain the content of operand2. If the comparison is false, sy-fdpos contains the offset of operand2 in operand1. If the comparison is true, sy-fdpos contains the length of operand1.
CP Covers Pattern: True, if the content of operand1 fits the pattern in operand2. Wildcard characters can be used to create the operand2 pattern, where "*" represents any character string (including a blank string) and "+" represents any character. It is not case-sensitive. Trailing blanks in the left operand are respected. If the comparison is true, sy-fdpos contains the offset of operand2 in operand1, whereby leading wildcard characters "*" in operand2 are ignored if operand2 also contains other characters. If the comparison is false, sy-fdpos contains the length of operand1. Characters in operand2 can be selected for direct comparisons by prefixing them with the escape character"#". For characters flagged in this way in operand2, the operator is case-sensitive. Also, wildcard characters and the escape character are not subject to special handling and trailing blanks are relevant.
NP No Pattern: True, if a relational expression with CP is false, that is, if operand1 does not fit the pattern operand2. If the comparison is false, sy-fdpos contains the offset of operand2 in operand1, whereby leading wildcard characters "*" in operand2 are ignored if operand2 also contains other characters. If the comparison is true, sy-fdpos contains the length of operand1.

Notes

  • The operators CP and NP
    use multiple wildcard characters "*" in a row in the
    same way as a single "*" character. The wildcard
    character "+" does not represent a blank string.
  • The statement FIND and the search functions find can be
    quicker than the relational operator CS by some
    magnitude.

Example

Searches for HTML tags in a text using operator CP.
This search finds the first HTML tag "<i>" at offset 8. Note that it is
not enough to specify a search pattern "<*>",
since CP stands for Covers Pattern, and not for
Contains Pattern. The example also shows that leading wildcard characters "*" in the string are ignored in sy-fdpos so that the occurrence found by this search can be
identified.

DATA html TYPE string.

html = `This
is <i>italic</i>!`.

IF html CP '*<*>*'.

  cl_demo_output=>display_text( |Found HTML tag at { sy-fdpos }| ).

ENDIF.

以上字符串的比较,都是有返回sy-fdpos

CS在很多的时候可以看成SEARCH/FIND使用,但是对特殊字符,CS要优先于其他。

ABAP中字符串相关比较的更多相关文章

  1. 理解CSV文件以及ABAP中的相关操作

    在很多ABAP开发中,我们使用CSV文件,有时候,关于CSV文件本身的一些问题使人迷惑.它仅仅是一种被逗号分割的文本文档吗? 让我们先来看看接下来可能要处理的几个相关组件的词汇的语义. Separat ...

  2. js中字符串相关知识点总结

      有引号就是字符串类型 空格也算长度 字符串的length不可写 typeof 判断数据类型 var s="a bcadde你好" // alert(typeof s)      ...

  3. PostgreSQL中字符串相关问题

    PostgreSQL的字符串类型有character.character varying和text的值.在使用character类型的时候, 它有自动填充空白的潜在影响,特别是在其它数据库(MySQL ...

  4. Java中字符串相关操作(判断,增删,转换)

    1:判断字符串中是否包含某个字符(字符串): startsWith(): 这个方法有两个变体并测试如果一个字符串开头的指定索引指定的前缀或在默认情况下从字符串开始位置 此方法定义的语法如下: publ ...

  5. 字符串处理:ABAP中的正则表达式

    声明:原创作品,转载时请注明文章来自SAP师太技术博客( 博/客/园www.cnblogs.com):www.cnblogs.com/jiangzhengjun,并以超链接形式标明文章原始出处,否则将 ...

  6. Redis字符串(STRING)中BIT相关命令

    上篇文章我们对STRING数据类型中一些基本的命令进行了介绍,但是没有涉及到BIT相关的命令,本文我们就来看看几个和BIT相关的命令. 本文是Redis系列的第四篇文章,了解前面的文章有助于更好的理解 ...

  7. C/C++中的字符串相关姿势

    这是我在<程序设计实习>课程上作的pre,目标是对C/C++中字符串的相关内容作一个尽量完整的介绍.(对于OIer可能不太实用) 课件链接: https://files.cnblogs.c ...

  8. SAP ABAP 处理字符串串串串串串串串(详细)

    关于ABAP中处理字符串的方法,非常详细,学习过程中总结一下分享给大家,,, ABAP/4 提供多个处理类型 C 即字符串 的数据对象的关键字. 处理字符串 的方法有: 1.拆分字符串split 2. ...

  9. 常用linux 命令 -字符串相关

    参考网络文章,个人工作总结 题记:一般对字符串的操作有以下几种:求长度,截取字符串,拼接字符串,找字符串中某个字符的索引 1 expr 命令 1.1 定义 man 手册 Print the value ...

  10. 【Todo】字符串相关的各种算法,以及用到的各种数据结构,包括前缀树后缀树等各种树

    另开一文分析字符串相关的各种算法,以及用到的各种数据结构,包括前缀树后缀树等各种树. 先来一个汇总, 算法: 本文中提到的字符串匹配算法有:KMP, BM, Horspool, Sunday, BF, ...

随机推荐

  1. selenium自动化测试-获取网页截图

    今天学习下使用selenium自动化测试工具获取网页截图. 1,如果是简单获取当前屏幕截图只需要使用方法: driver.get_screenshot_as_file('screenshot.png' ...

  2. .NET周刊【3月第2期 2025-03-09】

    国内文章 记一次.NET内存居高不下排查解决与启示 https://www.cnblogs.com/huangsheng/p/18731382 本文讲述了一个ASP.NET Core gRPC服务迁移 ...

  3. WIN2012域用户添加和批量添加工具

    WIN2012域用户添加和批量添加,不需要进行复杂的进电脑管理去添加 直接在软件上就可单个用户添加,可批量添加,并把指定的用户加入组 可以自定义组织单位,使用起来比较简单方便. 链接:https:// ...

  4. 【Linux】5.10 输入输出重定向

    Shell 输入/输出重定向 大多数 UNIX 系统命令从你的终端接受输入并将所产生的输出发送回​​到您的终端.一个命令通常从一个叫标准输入的地方读取输入,默认情况下,这恰好是你的终端.同样,一个命令 ...

  5. 一个检查左右括号是否配对的语法检查器(c语言)

    目录 一.题目如下 二.解题思路 三.代码实现 四.测试结果 一.题目如下 通过键盘输入一个包括 '(' 和 ')' 的字符串string ,判断字符串是否有效.要求设计算法实现检查字符串是否有效,有 ...

  6. FastAPI中Pydantic异步分布式唯一性校验

    title: FastAPI中Pydantic异步分布式唯一性校验 date: 2025/04/02 00:47:55 updated: 2025/04/02 00:47:55 author: cmd ...

  7. HTB打靶记录-Administrator

    # 信息收集 nmap -sV -sC -O 10.10.11.42 Nmap scan report for 10.10.11.42 Host is up (0.70s latency). Not ...

  8. 🎀SQL注入拦截工具-动态order by

    简介 业务场景经常会存在动态order by 入参情况,在处理动态 order by 参数时,需要防止SQL注入攻击.SQL注入是一种常见的安全漏洞,攻击者可以通过这种手段操纵查询来执行恶意代码. 措 ...

  9. php 根据时间设置多少小时 ,前天,昨天,多少月,多少年

    public static function formatTime($time){ if (is_int($time)) { $time = intval($time); } elseif ($tim ...

  10. WPF封装一个懒加载下拉列表控件(支持搜索)

    因为项目中PC端前端针对基础数据选择时的下拉列表做了懒加载控件,PC端使用现成的组件,为保持两端的选择方式统一,WPF客户端上也需要使用懒加载的下拉选择. WPF这种懒加载的控件未找到现成可用的组件, ...