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. Windows 10右键添加 "在此处打开命令窗口" 菜单

    1.添加右键菜单的两种效果: 第一种是在 桌面/文件夹窗口中/选中文件夹上直接点击右键,显示"在此处打开命令窗口"选项,如图: 第二种是在 桌面/文件夹窗口中/选中文件夹上按住Sh ...

  2. BUUCTF---keyboard

    题目 ooo yyy ii w uuu ee uuuu yyy uuuu y w uuu i i rr w i i rr rrr uuuu rrr uuuu t ii uuuu i w u rrr e ...

  3. 【Java】异常处理

    异常的定义 异常:在Java语言中,将程序执行中发生的不正常情况称为"异常". (开发过程中的语法错误和逻辑错误不是异常) 1. 异常的体系结构 Java程序在执行过程中所发生的异 ...

  4. git 访问方式浅谈

    小小总结下git的访问方式,留爪. git访问方式简介 https:每次fetch/push/pull都需要输入username & password ssh:通过ssh-keygen生成的公 ...

  5. 用99元买的服务器搭一套CI/CD系统

    故事的开始是这样的:无聊的时候在阿里云买了一个99/年的服务,上面部署了一个Git服务,用于托管自己无聊时写的一些代码,顺便也拿它做开发服务器.为了方便应用管理,起初用docker来管理和部署应用,后 ...

  6. SearXNG私有化部署与Dify集成

    一.概述 SearXNG 是一个免费的互联网元搜索引擎,它聚合了来自各种搜索服务和数据库的结果,但摆脱了隐私追踪 -- 用户行为既不会被引擎跟踪也不会被分析. 功能特性 自托管,可以私有化部署 没有用 ...

  7. @Transactional的属性

    @Transactional的属性: isolation-Isolation:事务的隔离级别(与并发相关) noRollbackFor-Class[]:那些异常,事务可以不回滚 noRollbackF ...

  8. 深入理解Java虚拟机-JAVA内存模型与线程

    Java内存模型(JMM) JMM 的核心概念 主内存与工作内存: 主内存(Main Memory)是所有线程共享的内存区域,存放着所有变量的值 每个线程都有自己的 工作内存(Working Memo ...

  9. Windows端口号操作

    1.查看所有端口号:netstat -ano 2.查看端口号:netstat -ano | findstr "16888" 3.杀死进程:taskkill /f /pid 8524

  10. java 实现发送邮件功能

    最近工作项目中需要使用到邮件功能,参考网上的文章,实现了一个基于java的邮件发送功能:直接上代码: 1.依赖 <dependency> <groupId>org.spring ...