Adding numbers when one value is null

Hi,
I need a solution.
I am writing a flow service which add two numbers, i used pub.math.addInt(). I take two input i.e say A and B now I mapped A with num1 of the addInt() function and B with num2 of the addInt() function.
well.
now if I run it passing value A=5 and B=5 then it gives value=10, thats f9,but if I did not pass value in any of the variable then it gives b2b:exception saying that num1/num2 should have value.
is their any configuration level changes possible which provide me replace null value by 0 internally.
I don’t want to incorporate any extra step before calling this pub.math.addInt() service.

Thnks!

You’re going to need to incorporate another step before calling pub.math:addInt to replace null with 0. There is not any configuration that would do that.

Your post should have been a new thread, rather than added to an existing thread that is completely unrelated to your question.

hi

could you plz tell me how can i add new thread.
?

Go to the forum in which your post will best fit. Press the “New Thread” button near the top of the page.

Hi,

I have found one ans of my question.
using copycondition feature during mapping we can do perform this in one step only.
say when i map input parameter A to the num1 of the addInt service input then we need to do the following:

  1. make copycondition=true and set condition as “%A%!=$null”.
    2.on the num1 set value=0.
    3.unchecked the override pipeline value check box.

repeat the above steps for input variable “B” also.

so in a word the above 3 steps replace the null value by 0.

Thnx!

The technique you outline is doable, but it is not very readable and is not a common approach. I usually recommend not using copy conditions.

What’s the objection to having a step or 2 befor the call to add?

actually I found WM provides us one facility for safe math . but , why you don’t suggest to use the COPY CONDITION ?

As mentioned above, I tend to avoid copy conditions because 1) they are not readily viewable; 2) it is not a commonly used facility. Because of this it is easy for a developer to miss that a copy condition is in place and it takes more effort to figure out what the code is doing. A BRANCH step is easier to read and understand.

If you’re referring to the math services in PSUtilities be careful about using the services with float or double in the name. With those services it is possible to get inaccurate results due to the nature of floating point arithmetic.