Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us in Bucharest on Sept 18th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

[resolved] Adding expressions to tMap component

Hello, I'm new with Talend an also Java, so I think my problem must be very easy to solve..
I'm using a tMap component to Map two fields from two different files (Price1 and Price2), these fields are BigDecimal (they are Prices, I think this is correct).
I need to generate an output file with all data from the first file and a new field Price3 with the sum of Price1 and Price2, but if I define a expression like Price1+Price2 to define Price3 field, it says me that the operator + cannot be used with BigDecimal data types. So, how can I define a expression to add two fields if they are BigDecimals?

Regards.
Labels (3)
1 Solution

Accepted Solutions
Anonymous
Not applicable
Author

Hello
You should filter null row on price2 column. eg:
row2.Price2==null?row1.Price1:row1.Price1.add(row2.Price2)
Best regards
shong

View solution in original post

4 Replies
Anonymous
Not applicable
Author

Hello
try
row1.Price1.add(row2.Price2)

Best regards

shong
Anonymous
Not applicable
Author

Hello Shong, thank yo for your response, but I have used it before and the result is this NullPointer exception:
Exception in component tMap_2
java.lang.NullPointerException
at java.math.BigDecimal.matchScale(Unknown Source)
at java.math.BigDecimal.add(Unknown Source)

Regards
Anonymous
Not applicable
Author

Hello
You should filter null row on price2 column. eg:
row2.Price2==null?row1.Price1:row1.Price1.add(row2.Price2)
Best regards
shong
Anonymous
Not applicable
Author

Hello Shong, now all is fine!!
Thank you for your responses.
Regards