Finding negative numbers in a field in ILog
-
26-12-2019 - |
Pregunta
I have a following requirement in Ilog Jrules,
Having an Integer field that contains both positive and negative numbers. Requirement is to loop through the Integer field, find and remove the negative sign in the negative numbers. It sounds simple but I could n't find a way to to this.
Any help or pointers would be highly appreciated. Many thanks.
Solución 2
I ve created the following function in BOM to XML mapping and passing all the incoming integer field values through this, which solved the problem.
if (integer < 0) return integer * -1; else return integer;
Otros consejos
(Supposing that XArray is an input/output Array of Integer in your rule project) You can create a rule like this:
definitions
set 'x' to a Number from XArray;
if
x is less than 0
then
set x to -x;
PS: don't forget to add the rule in a ruleTask (with RetePlus Alogorithm: default) in the main ruleflow.