Filter: string / integer

One Star

Filter: string / integer

Hello,
I want to test the values of a field (ACBAC) in a tmap component:
row1.PFUNCO==4?StringHandling.LEFT(StringHandling.TRIM(row1.PFPN),8)+"/"+StringHandling.TRIM(row1.PFUNCO)Smiley FrustratedtringHandling.TRIM(row1.PFPN)+"/"+StringHandling.TRIM(row1.PFUNCO)
currently it does not work!
It is strange because when I check the data type, ACBAC is an integer and when I test as an integer I get the following error:
Exception in thread "main" java.lang.Error: Unresolved compilation problem:
Incompatible operand types String and int
When I test it as a string I don't have the error:
Starting job ArticlesUCv2 at 08:12 10/06/2009.
connecting to socket on port 3463
connected
disconnected
Job ArticlesUCv2 ended at 08:12 10/06/2009.
but it does always the "else" part of the condition.
example of the output data:
15366M0500/881 PPE MAZOUT AS47A 4
15366M0545/881 PPE MAZOUT AS47A +CABLE 4
15366P0500/K10 PPE MAZOUT AS47A 4
15366P0500/111 PPE MAZOUT AS47A 4
15366P0500/121 PPE MAZOUT AS47A 4

as you see I have ACBAC=4 and it does not extract the left part of the firts field
Any ideas how to debug it?
Thanks
Didier
One Star

Re: Filter: string / integer

new attached screenshot
Highlighted
One Star

Re: Filter: string / integer

screenshot
Community Manager

Re: Filter: string / integer

Hello
, ACBAC is an integer and when I test as an integer I get the following error:

ACBAC is an integer, but you set a string to it, so it will throws this exception.
as you see I have ACBAC=4 and it does not extract the left part of the firts field

From your result, I see this is one of records of PFUNCO:
881 PPE MAZOUT AS47A 4
Only the last char is 4, why don't you say 'I have ACBAC=4', you need get the last char and set it as condition.
Aslo, if the data type of ACBAC is string, you should define the expression as:
row1.PFUNCO.equals("xxx")?StringHandling.LEFT(StringHandling.TRIM(row1.PFPN),8)+"/"+StringHandling.TRIM(row1.PFUNCO)Smiley FrustratedtringHandling.TRIM(row1.PFPN)+"/"+StringHandling.TRIM(row1.PFUNCO)
----------------------------------------------------------
Talend | Data Agility for Modern Business
One Star

Re: Filter: string / integer

Hi Shong,
Thanks for your recommandations
I have found my misstake
Didier

2019 GARNER MAGIC QUADRANT FOR DATA INTEGRATION TOOL

Talend named a Leader.

Get your copy

OPEN STUDIO FOR DATA INTEGRATION

Kickstart your first data integration and ETL projects.

Download now

What’s New for Talend Summer ’19

Watch the recorded webinar!

Watch Now

Best Practices for Using Context Variables with Talend – Part 4

Pick up some tips and tricks with Context Variables

Blog

How Media Organizations Achieved Success with Data Integration

Learn how media organizations have achieved success with Data Integration

Read

Tutorial

Introduction to Talend Open Studio for Data Integration.

Watch