Six 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?

  • Data Integration
2 ACCEPTED SOLUTIONS

Accepted Solutions
Seven Stars TRF
Seven 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
Seven Stars TRF
Seven 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
8 REPLIES
Seven Stars TRF
Seven 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))

 

 

Nine Stars

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

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

Rilhia Solutions
Seven Stars TRF
Seven Stars

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

@Sara, is your case solved?

TRF
Six 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

Six 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?

 

Seven Stars TRF
Seven 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
Six Stars

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

Hi @TRF,

 

Thanks a lot! 

 

Working Fine...