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

Announcements
Streamlining user types in Qlik Cloud capacity-based subscriptions: Read the Details
cancel
Showing results for 
Search instead for 
Did you mean: 
gt0731
Contributor III
Contributor III

tmap-Double type Division

I have been bashing my head against the wall for like 5 hours now trying to figure out why in the world double Outpucol = 315.0/23.0; is telling me that answer is 315.0
We have talend tool uses java code.
Input:
in tmap component Output mapping field Expression is
Outputcol---->row1.inputcol=="CS"?Double.valueOf(Var.Var3)/Double.valueOf(Var.Var5):Double.valueOf(Var.Var3)

Symptom : when running the job not getting any error on execution. But at the same time not getting desired output of division of double.
We also tried
firstdouble.divide(secondDouble)


Is there a alternate way or possible workaround for such values division?
Thanks in advance!
Labels (3)
11 Replies
vapukov
Master II
Master II

just need double check source data and logic, all must work
better to change == for equals() and also trim all input column (advanced settings or manually) - "CS" !=" CS"
0683p000009MBsk.png  0683p000009MBlu.png 0683p000009MBsp.png  0683p000009MBsu.png
Anonymous
Not applicable

I will advice use  row1.inputcol.equals("CS") in place of row1.inputcol == "CS"
gt0731
Contributor III
Contributor III
Author

Thanks for reply. I resolved the error by using  above mentioned expression.
Just after running the job getting  Null exception  error  which is more pain to identify where it comes from:
Here is complete detail on it.
Expression used in tmap 
code type var2:
row2.col3.equals("CS")?row2.col1.substring(0,row2.col1.lastIndexOf("-")+1)+"01":row2.col1 


Calling in Output field as External ID
Var.Var1+"-2016-"+TalendDate.formatDate("MMMM",row1.Date)+"-"+Var.Var2;


For ex:  my Stockcode Look like ABC-BCD-5OZ-24
want to fetch  this as  ABC-BCD-5OZ-01
using this expression
row2.col3.equals("CS")?row2.col1.substring(0,row2.col1.lastIndexOf("-")+1)+"01":row2.col1 
Extrnal ID  Looks like in Output section is 
Concatenation of Var.Var1+"-2016-"+TalendDate.formatDate("MMMM",row1.Date)+"-"+Var.Var2;
means    ABCD-2016-November-ABC-BCD-5OZ-01
But Due to null pointer error 
 Debug run is answering    ABCD-2016-November-null.
Any help on it would be much appreciated ! 
Thanks for valueable time.

Job design 
0683p000009MBsz.png
Getting null pointer exception 
Stacktrace is :
Exception in component tXMLMap_1
java.lang.NullPointerException
at bigdata.copy_of_forecastftpsuccessread_0_1.Copy_of_ForecastFTPSuccessRead.tFileList_1Process(Copy_of_ForecastFTPSuccessRead.java:1740)
at bigdata.copy_of_forecastftpsuccessread_0_1.Copy_of_ForecastFTPSuccessRead.runJobInTOS(Copy_of_ForecastFTPSuccessRead.java:4053)
at bigdata.copy_of_forecastftpsuccessread_0_1.Copy_of_ForecastFTPSuccessRead.main(Copy_of_ForecastFTPSuccessRead.java:3852)
2016-10-14 

Here is mapping screenshot :
0683p000009MBnr.png
0683p000009MBib.png
vapukov
Master II
Master II

Of course! 🙂
because Your flow "row2" not have col1 and col2 (it was in my example)
change them to Your name of columns
it look like You provide there one formulas and on screenshort - completely other
gt0731
Contributor III
Contributor III
Author

here  i replaced  the  exact expression of  Var2 :
row2.OtherUom.equals("CS")?row2.StockCode.substring(0,row2.StockCode.lastIndexOf("-")+1)+"01":row2.StockCode 
calling in output field as external ID
Var.Var1+"-2016-"+TalendDate.formatDate("MMMM",row1.Date)+"-"+Var.Var2;
But it also give me the same error. please guide on this issue
vapukov
Master II
Master II

First of all - You are use left JOIN (it is default)
it mean if for first row - no matched rows in lookup file, You will have NullPointer error at least for index function, You must handle NULL
run Job in debug mode for check - what coming from XML, then manually find it in lookup file and etc 
gt0731
Contributor III
Contributor III
Author

Yes,we are using join  model -INNER JOIN . then  also it is causing the error.
I rechecked  XML also  which is my  another data source   it is not null  in nature. 
I am   still trying to Identify how to prevent this Null pointer exception.
Thanks for the valuable time.
vapukov
Master II
Master II

what is show in debug mode?
what first row2, what first in row1?
gt0731
Contributor III
Contributor III
Author

Here is screenshot 
in flow   it is showing  50 rows transferred from input ------>tmap --------->0 rows obtained  at Output (When doing Inner join)
  50 rows transferred from input ------>tmap --------->50 rows obtained  at Output (When doingLeft join) it is throwing null pinter error 
and  when i do debug run on 
 Output  @ 50 th row   that is External ID  which i am  upserting against   SFDC  is  ABC -2016-July-null  which should be WITZ-2016-July-BCD-8OZ-01.