Avoid special characters on tmap

Six Stars

Avoid special characters on tmap

Hi,

 

I have been trying to avoid the special character like 312328-342344 ("-") and have output as 312328342344 or even 312328 342344  but it is not happening. Can you please help me on this. I did try the following;

row2.ColumnName.replaceAll("[-]", "")  and more but it doesn't work, I keep getting error. This has a data type string by the way. Can somebody help on this?


Accepted Solutions
Nine Stars

Re: Avoid special characters on tmap

try this

replaceString.PNG

Regards,

Veeru Boppudi

All Replies
Sixteen Stars

Re: Avoid special characters on tmap

 Your code should work. What is the error? Is it a nullpointerexception? If so, use this code....

row2.ColumnName!=null ? row2.ColumnName.replaceAll("[-]", "") : row2.ColumnName
Six Stars

Re: Avoid special characters on tmap

Hi,

 

Thanks for the response, it is not null pointer error. I get below error;

Error Line: 3791

Detail Message: The operator || is undefined for the argument type(s) boolean, String

 

Nine Stars

Re: Avoid special characters on tmap

Hi,

 

Error is not with replace function. are you using any concatenation function in tMap? Please provide tMap configurations.

 

Regards,

Veeru Boppudi
Six Stars

Re: Avoid special characters on tmap

Hi Boppudi,

 

I am attaching the tmap expressions. Please let me know if any further questions.

 

 

Nine Stars

Re: Avoid special characters on tmap

I think it's syntax error. Can you please provide more details what you are doing in tMap. Why are you using || in coding?

 

Regards,

Veeru Boppudi
Sixteen Stars

Re: Avoid special characters on tmap

Your expression is wrong. I suspect you are wanting to say....

 

"If AdminSystemValue is "CDB_AP" or

If AdminSystemValue is "CDB_CO" or

If AdminSystemValue is "CDB_CS" or.....etc

THEN replace all of the "-" chars in the AdminPartyId String"

 

In order to do that you need an inline IF. Something like this....

row2.AdminSystemValue!=null && (row2.AdminSystemValue.equals("CDB_AP") ||
row2.AdminSystemValue.equals("CDB_CO") || row2.AdminSystemValue.equals("CDB_CS")) ? row2.AdminPartyId.replaceAll("[-]","") : row2.AdminPartyId

I've given an example, not the complete code.

Six Stars

Re: Avoid special characters on tmap

Hi, as you see on screenshot other are the filters to get the data I like to have in output. Suppose

row2.AdminSystemValue.equals("CR") pulls CR data and || is or character to add more filters. Above

row2.AdminPartyId.replaceAll("[-]", "") is working and I get out as expected. When I put

row2.AdminPartyId.replaceAll("[-]", "") then get that error shared.

Nine Stars

Re: Avoid special characters on tmap

This is because row2.AdminSystemValue.equals("CR") gives you TRUE OR FALSE, but row2.AdminPartyId.replaceAll("[-]", "") will give you return value after replace. As per my knowledge you can not use different boolean and string value functions in the same function. 

 

Regards,

Veeru Boppudi
Sixteen Stars

Re: Avoid special characters on tmap

You can use an inline IF as I have demonstrated above

Six Stars

Re: Avoid special characters on tmap

Hi, I tried your logic in tMap but it doesn't seem it is working.

I am trying to avoid "-" from AdminPartyId and only want those values given for AdminSystemValue. I can get those values on AdminSystemValue with the logic I have but never for AdminPartyId.

Sixteen Stars

Re: Avoid special characters on tmap

You need to give a bit more information. What exactly did you try (ie show the code....copy and paste it here)? What was the error message?

Six Stars

Re: Avoid special characters on tmap

Hi, Please forget about the other filters. Now I only have

row2.AdminPartyId.replaceAll("[-]","")

Could you please help me getting rid of "-" character from AdminPartyId?

Sixteen Stars

Re: Avoid special characters on tmap

That should work. The only thing you are possibly missing is a check for null. Are you getting any errors or is it just not removing the "-"? Can you show how this is used in your tMap? A screenshot of your complete tMap may help

Six Stars

Re: Avoid special characters on tmap

Hi, I am getting error with just the filter (

row2.AdminPartyId.replaceAll("[-]","") )

 and below is the error message;

Error Line: 3791

Detail Message: Type mismatch: cannot convert from String to boolean

 

Sixteen Stars

Re: Avoid special characters on tmap

Can you please take a screenshot of your tMap? You are leaving out important information. The error...

Type mismatch: cannot convert from String to boolean

....suggests that you are trying to set a boolean value with a String. This suggests to me that either you are setting an incorrect column type OR you are using that logic in a filter. I cannot tell when you post your code. It MUST be a screenshot.

Six Stars

Re: Avoid special characters on tmap

Hi,

Attaching the screenshot. Please let me know if any questions.

Nine Stars

Re: Avoid special characters on tmap

Hi,

Are you using replace function in filter ? if yes then what are you trying to get out put?

You can use variable ports in tMap to clean data first then use that variable port in filter.

 

Regards,

 

 

Veeru Boppudi
Six Stars

Re: Avoid special characters on tmap

I was trying with replaceAll function to avoid "-". So you think I need to do on Variable ports? Could you please suggest me exactly what I need to mention as expression?

 

Nine Stars

Re: Avoid special characters on tmap

try this

replaceString.PNG

Regards,

Veeru Boppudi
Six Stars

Re: Avoid special characters on tmap

Did exactly same. It worked. Thanks a lot.