Tmap generating sequence number

Four Stars

Tmap generating sequence number

 I am working on generating multiple excel output files and using numeric sequence in Tmap to generate sequence numbers. The sequence number for these records should be same across all the sheets.


e.g.,One of the output sheets is a phone numbers sheet and there are 10 records and some of them do not have phone numbers and are null.


So, I used tfilterRow to remove the null values and only pass the records which have phone numbers. The problem here is, the Sequence number that is generated for this Sheet is not the same as previous sheets.


For E.g., There are 10 customers and say 3,6 and 9 do not have a phone number, the sequence should generate as





Phone7, Phone8 and Phone10.


Instead the Talend is generating a sequence Phone1,2,3,4,5,6,7 etc.


I need a solution where the sequence number is not effected by the null records. If there is a null record, skip it and generate the next sequence number.




Ten Stars

Re: Tmap generating sequence number

in tMap:
if row1.phonenumber == null ? null : sequencefunction()
Six Stars

Re: Tmap generating sequence number

I think you can try generating your sequence numbers and associating them before removing the null values.

In my opinion that should work, otherwise i don't have any other idea right now.

Seven Stars

Re: Tmap generating sequence number

you can generate a sequence in tmap itself and then use tfilterrow. So, your job should be like:


tmap with fields (phone_number,numeric.sequence("s1",1,1)) --> tfilterrow 

Don't forget to give kudos when a reply is helpful and click Accept the solution when you think you're good with it.
Seven Stars

Re: Tmap generating sequence number

Create Variable in tMap


row4.Mobile == null || row4.Mobile.equals("") ? 0 : Numeric.sequence("s2",1,1)