SAP CHAR COMP OP VS FUNCT



Get Example source ABAP code based on a different SAP table
  



ABAP_RELEXP - Comparison Operators vs. Predicate Functions
Instead of the comparison operators for character-like data types, predicate functions can be used as shown in the following table: Comparison OperatorPredicate Function o1 CO o2NOT contains_any_not_of( val = o1 sub = o2 ) o1 CN o2contains_any_not_of( val = o1 sub = o2 ) o1 CA o2contains_any_of( val = o1 sub = o2 ) o1 NA o2NOT contains_any_of( val = o1 sub = o2 ) o1 CS o2contains( val = to_upper( o1 ) sub = to_upper( o2 ) ) o1 NS o2NOT contains( val = to_upper( o1 ) sub = to_upper( o2 ) )
Since the comparison operators CS and NS are not case-sensitive, the arguments must be processed by the functions to_upper (or to_lower ). It should also be noted that the trailing blanks of character-like arguments of fixed length are always ignored in the predicate functions, whereas there are exceptions to this rule for operands of comparison operators.
The operators CP and NP can also be replaced by the predicate function contains or matches and a suitable regular expression. The differences in case handling must also be respected, whereby a simple mapping like in CS and NS is not possible, but usually not required.

ABAP_EXAMPLE_VX5
The following two relational expressions yield the same result.
ABEXA 01477
ABAP_EXAMPLE_END