Docs / Mapper Comparisons
Compare text and numbers in X12 Mapper
Choose the comparison that matches the business value you are checking. A unit code may need a match that ignores letter case, while a unit price usually needs numeric equality.
Compare text with %== and %!=
%== compares text for equality while ignoring letter case. %!= checks that the text differs while ignoring letter case.
Both operators convert their operands to string representations before comparing. A numeric operand is accepted through that conversion: the number 2 becomes the text "2". The operation remains a text comparison. It does not normalize decimal formatting, so "12.50" and "12.5" differ.
These rules apply whether the value comes from a literal, variable, element, or function result. They apply in arrow filters and ordinary conditions, including loop filters.
Choose text or numeric equality in an arrow filter
Consider this line in an 850 purchase order. Its line number is 1, quantity is 2, unit code is EA, and unit price is 12.50:
PO1*1*2*EA*12.50**UP*01234567890~
Each example below prints the line number when the filter matches:
print(ST->PO1[03 %== "ea"](01)) // 1: ignores letter case
print(ST->PO1[02 %== 2](01)) // 1: compares "2" with "2"
print(ST->PO1[04 %== 12.50](01)) // 1: identical price text
print(ST->PO1[04 %== 12.5](01)) // no output: different price text
print(ST->PO1[04 %!= 12.5](01)) // 1: different price text
print(ST->PO1[04 == 12.5](01)) // 1: equal numeric prices
For arrow filters, == and != use numeric comparison when the right operand is a number. Use a quoted string for an exact, case-sensitive text comparison, such as ST->PO1[03 == "EA"]. Use %== or %!= when comparing text while ignoring letter case.
If price formatting should not affect equality, use numeric ==. If a text code's spelling matters, compare its text. The choice of operator determines the comparison; a numeric operand does not give case-insensitive comparison a numeric meaning.
Use the same text rule in conditions
This loop also prints 1 for the example line:
amount=12.50
forEach(line in ST->PO1 : line(04) %== amount) {
print(line(01))
}
Changing amount to 12.5 makes the text comparison fail. To match numerically equal prices regardless of those decimal zeros, use == instead.
Check the result on your sample
Open the Mapper workspace and run the filter against a complete X12 sample. Save representative formatting and capitalization variations as mapping test cases when you want to preserve the intended behavior. The Mapper Built-ins reference covers functions you can use to prepare comparison values.