How to multiply field values by a number
Posted on October 4, 2011 at 2:16am
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?
Posted on October 4, 2011 at 3:21am
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)