One Star

How to multiply field values with numbers

I have an ETL job that uses the tMap control to map a BigDecimal input field to a BigDecimal output field. The result in the output field should be Raw.TranAmount * 0.07. The expression in the tMap mapping is as below:
Raw.TransactionType == 1 && Raw.AgentNo > 100000 ? Raw.TranAmount * 0.07 : 0
Basically, if transactiontype = 1 and agentno > 100000 then set the output to tranmount * 0.07
However I get java compilation errors saying that 'The operator * is undefined for the argument type(s) BigDecimal, double'. If I try the following:
Raw.TransactionType == 1 && Raw.AgentNo > 100000 ? 10 * 0.07 : 0
that works fine, so I know it is just having a problem multiplying the value from field Raw.TranAmount with 0.07.
I've tried various java/groovy functions like .multiply but still no good. Surely someone must have needed to do this before. Any suggestions (I'm new to Groovy)?
One Star

Re: How to multiply field values with numbers

After trawling this forum, found a resolution that works for me (thanks to bouga74):
Raw.TransactionType == 1 && Raw.AgentNo > 100000 ? Raw.TranAmount.multiply(BigDecimal.valueOf(0.07)) : new java.math.BigDecimal(0)
I had previously also tried the .multiply function but then the problem was that the 0.07 was not a BigDecimal itself!