-1

I have an excel which has few fields. I want to extract only those fields which has a special character ? in the values. I tried with the contains method in tmap without putting in condition for null but I am getting this NullPointer Exception as the fields also contain blank values in those fields.

Here are the excel file :

enter image description here

Here is the tmap filtering : enter image description here

Here is the error screen :

enter image description here

user1538020
  • 515
  • 1
  • 9
  • 25
  • Is the target column nullable? i.e, Is the field in which you are trying to store the output of this expression nullable? – Rohit Ranjan Mar 10 '16 at 14:24
  • The target is nullable. The TMAP just had row1.Global_Description.contains("?")||row1.Lead_Product_Segment.contains("?"). I was getting a NullPointerException due to this..And so I was trying to handle null in here but the syntax isn't proper.. how can we handle null in this statement? – user1538020 Mar 12 '16 at 05:27
  • See revised answer . – dbh Mar 13 '16 at 14:25

1 Answers1

0

One or both of the fields in your expression builder has a null in it. You must check for null before performing string contains. Otherwise it will get a null pointer exception

The below expression will produce a Boolean value of true or false. You can use this expression to filter which rows go onto the output of the tMap

(row1.Global_Description!=null && row1.Global_Description.contains("?"))|| (row1.Lead_Product_Segment!=null && row1.Lead_Product_Segment.contains("?"))

dbh
  • 1,607
  • 13
  • 18
  • The target is nullable. The TMAP just had row1.Global_Description.contains("?")||row1.Lead_Product_Segment.contains("?"). I was getting a NullPointerException due to this..And so I was trying to handle null in here but the syntax isn't proper.. how can we handle null in this statement? – user1538020 Mar 12 '16 at 05:27