SAP LOGEXP STRINGS



Get Example source ABAP code based on a different SAP table
  


• # ABAP_ESCAPE
• CO ABAP_LOGICAL_OPERATOR
• CN ABAP_LOGICAL_OPERATOR
• CA ABAP_LOGICAL_OPERATOR
• NA ABAP_LOGICAL_OPERATOR
• CS ABAP_LOGICAL_OPERATOR
• NS ABAP_LOGICAL_OPERATOR
• CP ABAP_LOGICAL_OPERATOR
• NP ABAP_LOGICAL_OPERATOR
• * CP
• * NP
• + CP
• + NP

ABAP_RELEXP - Comparison Operators for Character-Like DataTypes
The following table shows the comparison operators for comparisons between character-like operands (single data objects and return values or string expressions) in comparison expressions. Trailing blanks are respected for operands of type string. Unless documented differently in the following table, trailing blanks are not respected for operands of types c , d, n, and t. <(>operator<)>Meaning ABAP_KEY COContains Only: True if operand1 only contains characters from operand2. Uppercase and lowercase characters and trailing blanks are respected for both operands. If operand2 is of type string and initial, the comparison expression is false, unless operand1 is also of type string and initial, in which case the comparison expression is always true, regardless of operand2. If the comparison is false, 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. ABAP_KEY CNContains Not Only: True, if a comparison 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. ABAP_KEY CAContains Any: True, if operand1 contains at least one character from operand2. Uppercase and lowercase characters and trailing blanks are respected for both operands. If operand1 or operand2 is of type string and initial, the comparison expression is always false. If the comparison is true, 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 . ABAP_KEY NAContains Not Any: True, if a comparison expression with CA is false, that is, 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 . ABAP_KEY CSContains String: True, if the content of operand2 is contained in operand1. Uppercase and lowercase characters 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 comparison expression is false, unless operand2 is also of type string and initial, or of type c and only contains blank characters, in which case, the comparison 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. ABAP_KEY NSContains No String: True, if a comparison 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. ABAP_KEY CPConforms to Pattern: True, if the content of operand1 matches the pattern in operand2. Wildcard characters can be used to form the operand2 pattern, where * represents any character string, including an empty 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 marked for direct comparisons by prefixing them with the escape character #. For such characters in operand2, the operator is case-sensitive, wildcard characters and the escape character are not subject to special handling and trailing blanks are relevant. ABAP_KEY NPDoes Not Conform to Pattern: True, if a comparison expression with CP is false, that is, operand1 does not fit the pattern in 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 .



Latest notes:

For the operators CP and NP, multiple wildcard characters * one after another have the same effect as the specification of a single wildcard * character. The wildcard character + does not represent an empty string.
When using the operators CP and NP, patterns without wildcard characters in operand2 do not make any sense. Instead, a comparison with = can be performed.
Operands of byte-like data types cannot be compared using the comparison operators from this table. To perform corresponding comparisons for byte-like operands, comparison operators for byte-like data types can be used.
Instead of the comparison operators in this table predicate functions can also be used.
The statement FIND and the search functions find can be quicker than the comparison operator CS by some magnitude.
When using comparison operators for character-like data types in a conditional expression or in a Boolean function, the system field sy-fdpos has the value set in the expression once the expression is processed.
NON_V5_HINTS
ABAP_HINT_END

ABAP_EXAMPLE_VX5
Search for HTML tags in a text using the operator CP. This search finds the first HTML tag < i > at offset 8. It should be noted that it is not sufficient to specify a search pattern <(><*><)>, since CP stands for Conforms to Pattern and not for Contains Pattern. The example also shows that the leading wildcard characters * of the pattern are ignored in sy-fdpos, to determine the occurrence found by this search.
ABEXA 01116
ABAP_EXAMPLE_END

ABAP_EXAMPLE_VX5
Display of the first position of a letter in a field. The operator CS is used in the conditional operator COND, which returns the content of the system field sy-fdpos.
ABEXA 01117
ABAP_EXAMPLE_END

ABAP_EXAMPLE_VX5
The following comparison is always true, regardless of the input.
ABEXA 01118
ABAP_EXAMPLE_END

ABAP_EXAMPLE_ABEXA
Comparison Operators for Character-Like Data Types
ABAP_EXAMPLE_END