<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic {Resolved} Help Diagnosing Null Pointer in Talend Studio</title>
    <link>https://community.qlik.com/t5/Talend-Studio/Resolved-Help-Diagnosing-Null-Pointer/m-p/2320452#M90591</link>
    <description>&lt;P&gt;I'm having a null pointer exception when I test my job but according to the stack trace the problematic line of code is a simple assignment. The only way I'm aware of that this code could cause a null pointer exception is if WEXFuelTransform_tmp.DriverID doesn't exist on the class...any ideas?&amp;nbsp;In my tMap I have meticulously checked that every field is not null before calling a function on it.&lt;/P&gt; 
&lt;P&gt;&lt;SPAN class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture.PNG" style="width: 999px;"&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="0683p000009LyiJ.png"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/155605i5A6E699A767F963D/image-size/large?v=v2&amp;amp;px=999" role="button" title="0683p000009LyiJ.png" alt="0683p000009LyiJ.png" /&gt;&lt;/span&gt;&lt;/SPAN&gt;&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;Here is my tMap variable scope:&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;PRE&gt;{ // start of Var scope
	// ###############################
	// # Vars tables

	Var__tMap_1__Struct Var = Var__tMap_1;// ###############################
	// ###############################
	// # Output tables

	WEXFuelTransform = null;
	// # Output table : 'WEXFuelTransform'
	WEXFuelTransform_tmp.FuelTransactionID = 0;
	WEXFuelTransform_tmp.CardNumber = row1.CardNumber;
	WEXFuelTransform_tmp.CustomerVehicleID = row1.CustomerVehicleID;
	WEXFuelTransform_tmp.PostDate = row1.PostDate;
	WEXFuelTransform_tmp.TransactionTimestamp = row1.TransactionDate != null
		&amp;amp;&amp;amp; row1.TransactionTime != null ? TalendDate
			.parseDate(
					"MM/dd/yyyy HH:mm:ss a",
					row1.TransactionDate
					+ " "
					+ row1.TransactionTime)
			: null;
	WEXFuelTransform_tmp.Merchant = row1.Merchant;
	WEXFuelTransform_tmp.MerchantName = row1.MerchantName;
	WEXFuelTransform_tmp.MerchantAddress = row1.MerchantAddress;
	WEXFuelTransform_tmp.MerchantCity = row1.MerchantCity;
	WEXFuelTransform_tmp.MerchantState = row1.MerchantState;
	WEXFuelTransform_tmp.MerchantZipCode = row1.MerchantZipCode;
	WEXFuelTransform_tmp.DriverName = row1.DriverName;
	WEXFuelTransform_tmp.DriverID = row1.DriverID;
	WEXFuelTransform_tmp.CurrentOdometer = row1.CurrentOdometer;
	WEXFuelTransform_tmp.AdjustedOdometer = row1.AdjustedOdometer != null ? row1.AdjustedOdometer
			: row1.CurrentOdometer;
	WEXFuelTransform_tmp.Product = row1.Product;
	WEXFuelTransform_tmp.Units = row1.Units;
	WEXFuelTransform_tmp.UnitCost = DataParsing
		.parseAccountingValue(row1.UnitCost);
	WEXFuelTransform_tmp.FuelCost = DataParsing
			.parseAccountingValue(row1.FuelCost);
	WEXFuelTransform_tmp.NonFuelCost = DataParsing
			.parseAccountingValue(row1.NonFuelCost);
	WEXFuelTransform_tmp.GrossCost = DataParsing
			.parseAccountingValue(row1.GrossCost);
	WEXFuelTransform_tmp.ExemptTax = DataParsing
			.parseAccountingValue(row1.ExemptTax);
	WEXFuelTransform_tmp.TransactionFee = DataParsing
			.parseAccountingValue(row1.TransactionFee);
	WEXFuelTransform_tmp.NetCost = DataParsing
			.parseAccountingValue(row1.NetCost);
	WEXFuelTransform_tmp.ReportedTax = DataParsing
			.parseAccountingValue(row1.ReportedTax);
	WEXFuelTransform_tmp.MPG = row1.MPG != null ? Float
			.parseFloat(StringHandling.EREPLACE(row1.MPG, ",", ""))
			: null;
	WEXFuelTransform_tmp.CPM = DataParsing
			.parseAccountingValue(row1.CPM);
	WEXFuelTransform = WEXFuelTransform_tmp;
	// ###############################

} // end of Var scope&lt;/PRE&gt; 
&lt;P&gt;And here is the parseAccountingValue function:&lt;/P&gt; 
&lt;PRE&gt;/**&lt;BR /&gt; * parseAccountingValue: Takes in a dollar amount in accounting notation such as "$3.24" or "($0.60)" and returns a positive or negative decimal&lt;BR /&gt; * &lt;BR /&gt; * &lt;BR /&gt; * {talendTypes} String&lt;BR /&gt; * &lt;BR /&gt; * {Category} Data Parsing&lt;BR /&gt; * &lt;BR /&gt; * {param} string("world") input: The string need to be printed.&lt;BR /&gt; * &lt;BR /&gt; * {example} parseAccountingValue("($0.60)") # -0.60.&lt;BR /&gt; */&lt;BR /&gt;public static float parseAccountingValue(String value) {
    	if (value == null) {
    		return 0.0f;
    	}
    	float ret = -1;
        if (value.substring(0, 1).equals("(")) {
            ret = Float.parseFloat(value.substring(2, value.length()-1)) * -1;
        }
        else {
        	ret = Float.parseFloat(value.substring(1, value.length()));
        }
        return ret;
    }&lt;/PRE&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 27 Jun 2018 18:58:52 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2018-06-27T18:58:52Z</dc:date>
    <item>
      <title>{Resolved} Help Diagnosing Null Pointer</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Resolved-Help-Diagnosing-Null-Pointer/m-p/2320452#M90591</link>
      <description>&lt;P&gt;I'm having a null pointer exception when I test my job but according to the stack trace the problematic line of code is a simple assignment. The only way I'm aware of that this code could cause a null pointer exception is if WEXFuelTransform_tmp.DriverID doesn't exist on the class...any ideas?&amp;nbsp;In my tMap I have meticulously checked that every field is not null before calling a function on it.&lt;/P&gt; 
&lt;P&gt;&lt;SPAN class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture.PNG" style="width: 999px;"&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="0683p000009LyiJ.png"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/155605i5A6E699A767F963D/image-size/large?v=v2&amp;amp;px=999" role="button" title="0683p000009LyiJ.png" alt="0683p000009LyiJ.png" /&gt;&lt;/span&gt;&lt;/SPAN&gt;&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;Here is my tMap variable scope:&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;PRE&gt;{ // start of Var scope
	// ###############################
	// # Vars tables

	Var__tMap_1__Struct Var = Var__tMap_1;// ###############################
	// ###############################
	// # Output tables

	WEXFuelTransform = null;
	// # Output table : 'WEXFuelTransform'
	WEXFuelTransform_tmp.FuelTransactionID = 0;
	WEXFuelTransform_tmp.CardNumber = row1.CardNumber;
	WEXFuelTransform_tmp.CustomerVehicleID = row1.CustomerVehicleID;
	WEXFuelTransform_tmp.PostDate = row1.PostDate;
	WEXFuelTransform_tmp.TransactionTimestamp = row1.TransactionDate != null
		&amp;amp;&amp;amp; row1.TransactionTime != null ? TalendDate
			.parseDate(
					"MM/dd/yyyy HH:mm:ss a",
					row1.TransactionDate
					+ " "
					+ row1.TransactionTime)
			: null;
	WEXFuelTransform_tmp.Merchant = row1.Merchant;
	WEXFuelTransform_tmp.MerchantName = row1.MerchantName;
	WEXFuelTransform_tmp.MerchantAddress = row1.MerchantAddress;
	WEXFuelTransform_tmp.MerchantCity = row1.MerchantCity;
	WEXFuelTransform_tmp.MerchantState = row1.MerchantState;
	WEXFuelTransform_tmp.MerchantZipCode = row1.MerchantZipCode;
	WEXFuelTransform_tmp.DriverName = row1.DriverName;
	WEXFuelTransform_tmp.DriverID = row1.DriverID;
	WEXFuelTransform_tmp.CurrentOdometer = row1.CurrentOdometer;
	WEXFuelTransform_tmp.AdjustedOdometer = row1.AdjustedOdometer != null ? row1.AdjustedOdometer
			: row1.CurrentOdometer;
	WEXFuelTransform_tmp.Product = row1.Product;
	WEXFuelTransform_tmp.Units = row1.Units;
	WEXFuelTransform_tmp.UnitCost = DataParsing
		.parseAccountingValue(row1.UnitCost);
	WEXFuelTransform_tmp.FuelCost = DataParsing
			.parseAccountingValue(row1.FuelCost);
	WEXFuelTransform_tmp.NonFuelCost = DataParsing
			.parseAccountingValue(row1.NonFuelCost);
	WEXFuelTransform_tmp.GrossCost = DataParsing
			.parseAccountingValue(row1.GrossCost);
	WEXFuelTransform_tmp.ExemptTax = DataParsing
			.parseAccountingValue(row1.ExemptTax);
	WEXFuelTransform_tmp.TransactionFee = DataParsing
			.parseAccountingValue(row1.TransactionFee);
	WEXFuelTransform_tmp.NetCost = DataParsing
			.parseAccountingValue(row1.NetCost);
	WEXFuelTransform_tmp.ReportedTax = DataParsing
			.parseAccountingValue(row1.ReportedTax);
	WEXFuelTransform_tmp.MPG = row1.MPG != null ? Float
			.parseFloat(StringHandling.EREPLACE(row1.MPG, ",", ""))
			: null;
	WEXFuelTransform_tmp.CPM = DataParsing
			.parseAccountingValue(row1.CPM);
	WEXFuelTransform = WEXFuelTransform_tmp;
	// ###############################

} // end of Var scope&lt;/PRE&gt; 
&lt;P&gt;And here is the parseAccountingValue function:&lt;/P&gt; 
&lt;PRE&gt;/**&lt;BR /&gt; * parseAccountingValue: Takes in a dollar amount in accounting notation such as "$3.24" or "($0.60)" and returns a positive or negative decimal&lt;BR /&gt; * &lt;BR /&gt; * &lt;BR /&gt; * {talendTypes} String&lt;BR /&gt; * &lt;BR /&gt; * {Category} Data Parsing&lt;BR /&gt; * &lt;BR /&gt; * {param} string("world") input: The string need to be printed.&lt;BR /&gt; * &lt;BR /&gt; * {example} parseAccountingValue("($0.60)") # -0.60.&lt;BR /&gt; */&lt;BR /&gt;public static float parseAccountingValue(String value) {
    	if (value == null) {
    		return 0.0f;
    	}
    	float ret = -1;
        if (value.substring(0, 1).equals("(")) {
            ret = Float.parseFloat(value.substring(2, value.length()-1)) * -1;
        }
        else {
        	ret = Float.parseFloat(value.substring(1, value.length()));
        }
        return ret;
    }&lt;/PRE&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 27 Jun 2018 18:58:52 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Resolved-Help-Diagnosing-Null-Pointer/m-p/2320452#M90591</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2018-06-27T18:58:52Z</dc:date>
    </item>
    <item>
      <title>Re: {Resolved} Help Diagnosing Null Pointer</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Resolved-Help-Diagnosing-Null-Pointer/m-p/2320453#M90592</link>
      <description>&lt;P&gt;Found the problem. It looked like it was choking on the 152nd line of my csv, but the problem was actually with the 153rd line. One of my&amp;nbsp;columns was missing data and that was necessary because I had an index on the corresponding column on target database.&lt;/P&gt;</description>
      <pubDate>Wed, 27 Jun 2018 19:35:23 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Resolved-Help-Diagnosing-Null-Pointer/m-p/2320453#M90592</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2018-06-27T19:35:23Z</dc:date>
    </item>
    <item>
      <title>Re: {Resolved} Help Diagnosing Null Pointer</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Resolved-Help-Diagnosing-Null-Pointer/m-p/2320454#M90593</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;Thanks for posting that you have resolved your issue.&lt;/P&gt;
&lt;P&gt;Best regards&lt;/P&gt;
&lt;P&gt;Sabrina&lt;/P&gt;</description>
      <pubDate>Fri, 29 Jun 2018 04:48:52 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Resolved-Help-Diagnosing-Null-Pointer/m-p/2320454#M90593</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2018-06-29T04:48:52Z</dc:date>
    </item>
  </channel>
</rss>

