tmap and string contains

One Star

tmap and string contains

Hi,
I have a text string containing our order numbers. There is some logic in our text strings which I would like to use for mapping purposes and also to reduce them somewhat into groups.
An order number could be like X-54266-05-10 or Q-70563-01-15. I would then like to make two new columns by using for instance tmap
1) A column called "Type" which is derived when the order number contains "X-" and "-05" then the type is "Engineering" and if it contains "Q-" and "-01" it is "Components" etc.
2) A column called "Order short" which is defined by when the order is starting with "X" the length should be 7, so it in this example returns X-54266 and if the order starts with "Q" the length should be 10, so it returns Q-70563-01.
I have tried all sorts of things, but I haven't succeeded so I really hope you can help me.
Thanks.
MNP
Seven Stars

Re: tmap and string contains

row1.ColumnName.equals("") should solve your problem. By the way if your mater list is BIG to compare with, I'll suggest to include Lookup table or file.
One Star

Re: tmap and string contains

Hi,

Below one for your 1 question answer: use in 'Type' field expression
(row1.order_number.contains("-X")||row.order_number.contains("-05-"))?"Engineering":"Components"

Below one for second 2 question answer: use in 'Order_short' field expression
row1.order_number.contains("X")?(StringHandling.RIGHT(row1.order_number,7)):
(StringHandling.RIGHT(row1.order_number,10))

if order_number field contains data like
X-54266-05-10 or Q-70563-01-15 ..............
output like:
' Type' 'Order_short'
Engineering X-54266
Components Q-70563-01
In case
if order_number field contains data like(doesn't contains 'X' or 'Y')
54266-05-10 or 70563-01-15 ..........
output like:
' Type' 'Order_short'
Components 54266-05-1
Components 70563-01-1

Regards,
kumar.talend
One Star

Re: tmap and string contains

Thanks a lot for your replies. I have tried to do it like suggested by Kumar, and that works perfectly.