Restrict Incoming records by writing multiple conditions in tmap Expression filter

Seven Stars

Restrict Incoming records by writing multiple conditions in tmap Expression filter

Hi everyone,

My requirement is to load data from excel to oracle table which satisfies the condition written in tmap expression filter and I'm storing the rejected records in one file.

 

For example: In excel file which contains following records

VendorName,Type,Payment

John,Credits,10.23

Richard,credits,10.23

Maddy,credits,12.45

ABCD,Debit,12.87

cdef,debit,14.65

 

Expected output:

vendorname(varchar),Type(varchar),Payment(bigdecimal)

VendorName,Type,Payment

John,Credits,10.23

Richard,credits,10.23

 

Rejected records are :

Maddy,credits,12.45

ABCD,Debit,12.87

cdef,debit,14.65

 

The condition in tmap expression filter:

row1.Type.equals("Credits") && row1.payment == BigDecimal.valueOf(10.23)

 

In my case, its works fine for the single condition that is  row1.Type.equals("Credits") and All the records gets rejected for this condition row1.Type.equals("Credits") && row1.payment == BigDecimal.valueOf(10.23).

row1.Type.equals("Credits") && row1.payment == BigDecimal.valueOf(10.23).

 

can anyone help me out to resolve this issues?


Accepted Solutions
Fifteen Stars TRF
Fifteen Stars

Re: Restrict Incoming records by writing multiple conditions in tmap Expression filter

Hi,

 

Try to compare using:

 

row1.Type.equalsIgnoreCase("Credits") &&
row1.payment.compareTo(BigDecimal.valueOf(10.23)) == 0

Hope this helps.


TRF
Fifteen Stars TRF
Fifteen Stars

Re: Restrict Incoming records by writing multiple conditions in tmap Expression filter

Hi,

Try this:
row1.CREATION_DATE.compareTo(TalendDate.parseDate("dd-MM-yyyy", "05/17/2017")) == 0

TRF

All Replies
Fifteen Stars TRF
Fifteen Stars

Re: Restrict Incoming records by writing multiple conditions in tmap Expression filter

Hi,

 

Try to compare using:

 

row1.Type.equalsIgnoreCase("Credits") &&
row1.payment.compareTo(BigDecimal.valueOf(10.23)) == 0

Hope this helps.


TRF
Four Stars cjj
Four Stars

Re: Restrict Incoming records by writing multiple conditions in tmap Expression filter

Hi, 

 

I looks a bit like it could be down to logic formatting.

 

So you're using:

row1.Type.equals("Credits") && row1.payment == BigDecimal.valueOf(10.23)

But what you really mean is:

 

Type must equal credits AND payment must equal 10.23

 

 

The problem is, it will be reading the query as:

 

Type equals credits and payment EQUALS 10.23

 

 

It's worth separating the key conditions like so, and giving that a bash:

row1.Type.equals("Credits") && (row1.payment == BigDecimal.valueOf(10.23))

 

 

Community Manager

Re: Restrict Incoming records by writing multiple conditions in tmap Expression filter

@TRF is correct so long as your payment column is a BigDecimal

Fifteen Stars TRF
Fifteen Stars

Re: Restrict Incoming records by writing multiple conditions in tmap Expression filter

@Sara, is your case solved?

TRF
Seven Stars

Re: Restrict Incoming records by writing multiple conditions in tmap Expression filter

Hello @TRF,

 

Thank you so much.

The below code works fine.

row1.Type.equalsIgnoreCase("Credits") &&
row1.payment.compareTo(BigDecimal.valueOf(10.23)) == 0

 

I need a clarification to restrict data for Integer,float and date syntax

Seven Stars

Re: Restrict Incoming records by writing multiple conditions in tmap Expression filter

Hi,

 

For Date values I'm using below code 

row1.CREATION_DATE.after(TalendDate.parseDate("MM/dd/yyyy","05/17/2017"))

its working fine.

My question is how to specify some date, something like I should retrieve the record which is on 05/14/2017.

I don't want to mention "after and before " keyword I just want to specify exact date.

Is this possible?

 

Fifteen Stars TRF
Fifteen Stars

Re: Restrict Incoming records by writing multiple conditions in tmap Expression filter

Hi,

Try this:
row1.CREATION_DATE.compareTo(TalendDate.parseDate("dd-MM-yyyy", "05/17/2017")) == 0

TRF
Seven Stars

Re: Restrict Incoming records by writing multiple conditions in tmap Expression filter

Hi @TRF,

 

Thanks a lot! 

 

Working Fine...

Calling Talend Open Studio Users

The first 100 community members completing the Open Studio survey win a $10 gift voucher.

Start the survey

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

6 Ways to Start Utilizing Machine Learning with Amazon We Services and Talend

Look at6 ways to start utilizing Machine Learning with Amazon We Services and Talend

Blog