Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi,
I have to implement the below logic in Tmap:
If sku starts with ‘DE-TB%’ then ‘TB’
Elseif sku starts with ‘DE-SB%’ then ‘SB’
I tried something like below, but its not working
row4.SKU.contains("DE-TB%")?"TB":row4.SKU.contains("DE-SB%")?"SB":row4.SKU.contains("DE-SP%")?"SP":row4.SKU.contains("DE-LB%")?"LB":row4.SKU.contains("DE-WB%")?"WB":row4.SKU.contains("DE-DB%")?"DB":row4.SKU.contains("DE-CM%")?"CM":row4.SKU.contains("DE-PS%")?"PS":row4.SKU.contains("DE-PB%")?"PB":row4.SKU.contains("M1-TA%")?"TA":row4.SKU.contains("M1-PD%")?"PD":row4.SKU.contains("M1-PL%")?"PL":row4.SKU.substring(5,6)
if it doesnt match, then it should give the substring as from 5th position - 6 chars. How do i implement this?
With Java your don't need the %.
Try this one:
row4.SKU.startsWith("DE-TB") ? "TB" :
row4.SKU.startsWith("DE-SB") ? "SB" :
and so on...
Startswith is not working. Any other way we can do that?basically I want to use LIKE clause % in my query
@sushantk19 wrote:
Startswith is not working.
What doesn't work?
Do you any error?
Any compilation error?
Just an unexpected resulted?
What else?
yes, the output is not as expected. No errors as such.
As per the above mentioned logic, it is not able to read the input values such as "DE-TB%". It skips this condition and directly executes the else part.
With Java your don't need the %.
Try this one:
row4.SKU.startsWith("DE-TB") ? "TB" :
row4.SKU.startsWith("DE-SB") ? "SB" :
and so on...
worked perfectly fine!! thank so much!
issue was I was using % symbol like row4.SKU.startsWith("DE-SB%")