The following description shows the comparison operators for comparisons between charactertype operands.
In ABAP as standard, trailing blanks are taken into account for operands of type string
and are not taken into account for operands of type c, d, n and t.
1.CO(contains Only):
If operand1 contains only the characters from operand2, this comparison is true.
Trailing blanks are taken into account.
This is case sensitive.
If the comparison is false, SYFDPOS will give the offset of the first character
in operand1 that is not contained in operand2.
If the comparison if true, SYFDPOS contains the length of operand1.
Examples:
Positive Comparison.
data: char1(4) type c value 'abc ', 
Negative comparison.
data: 
2.CN(Contains not only):
If the operand1 contains not only the characters of operand 2, this comparison is true.
It is exactly opposite to CO pattern.
If the comparison is true, SYFDPOS will give the offset of the first character
in operand1 that is not contained in operand2.
If the comparison is false, SYFDPOS contains the length of operand1.
Examples:
Positive Comparison.
data: 
Negative comparison.
data: 
3.CA (Contains Any):
If operand1 contains at least one character of operand2, comparison is true.
It is case sensitive.
IF the comparison is true, SYFDPOS will give the offset of the first character in operand1
that satisfies the comparison.
If the comparison is false, SYFDPOS will contain the length of operand1.
Example:
Positive Comparison.
Result: 2. 
Negative comparison.
Result: 3. 
4.NA (contains Not Any):
If operand1 does not contain any of the characters of operand2, comparison is true.
It is case sensitive.
If the comparison is true, SYFDPOS contains the length of operand1.
If comparison is false, SYFDPOS contains the offset of the first character of operand1
that occurs in operand2.
Example:
Positive Comparison.
Result: 3. 
Negative comparison.
Result: 2. 
5.CS (Contains String):
If operand1 contains the string in operand2, the condition is true.
Trailing spaces are ignored and this is not case sensitive.
If the condition is true, SYFDPOS contains the offset of operand2 in operand1.
If it is false, SYFDPOS contains the length of operand2.
Example:
Positive Comparison.
Result: 2.

Negative comparison.
Result: 4.

6.NS (contains No String):
If operand1 does not contains the string operand2, comparison is true.
Trailing spaces are ignored and the comparison is not casesensitive.
If the comparison is true, the system field SYFDPOS contains the length of operand1.
If the comparison is false, SYFDPOS contains the offset of operand2 in operand1.
Example:
Positive Comparison:
data:
char1(4) type c value 'cD',
char2(4) type c value 'acbd'.
char2 NS char1.
Result: 4.
Negative comparison.
Result: 2. 
7.CP (Contains Pattern):
If operand1 contains pattern operand2, comparison is true.
Trailing spaces are ignored.
Comparison is NOT case sensitive.
If the comparison is true, the system field SYFDPOS contains the offset of operand2 in operand1.
If it is false, SYFDPOS contains the length of operand1.
Example:
Positive Comparison.
data:
char1(4) type c value '*c*',
char2(4) type c value 'abcd'.
char2 CP char1.
Result: 2.
Negative comparison.
data: Result: 4. 
8.NP (contains No Pattern):
If operand1 does not contains pattern operand2, comparison is true.
Trailing spaces are ignored.
Comparison is NOT case sensitive.
If it is true, SYFDPOS contains the length of operand1.
If the comparison is false, the system field SYFDPOS contains the offset of operand2 in operand1.
Example:
Positive Comparison.
Result: 4. 
Negative comparison.
Result: 2. 
Leave A Comment?
You must be logged in to post a comment.