How to multiply field values by a number

0
Code:
Hi,
  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, as seen below:
 
Raw.TransactionType == 1 && Raw.AgentNo > 100000 ? Raw.TranAmount * 0.07 : 0
 
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?
 
Thanks
Colin
</td></tr></tbody></table>
colinmrice's picture
Joined: Mar 24 2011 - 3:47am
Last seen: 9 years 1 week ago

1 Answer:

0
Found a resolution to this on the Talend forge forum:

Raw.TransactionType == 1 && Raw.AgentNo > 100000 ? Raw.TranAmount.multiply(BigDecimal.valueOf(0.07)) : new java.math.BigDecimal(0)
colinmrice's picture
Joined: Mar 24 2011 - 3:47am
Last seen: 9 years 1 week ago
Feedback