cancel
Showing results for 
Search instead for 
Did you mean: 

Deleting zeros

Former Member
0 Kudos

Hi,

I want to delete the zeros that comes after the incoming data. i.e. 000001230000 so I get 00000123.

How is that possible?

Best regards

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi

You can use FormatNum Function or UDF.

Parameter: str



if (str == null){
return null;}
char[] chars = str.toCharArray();int length,index ;length = str.length();
index = length -1;
for (; index >=0;index--)
{
if (chars[index] != '0'){
break;}
}
return (index == length-1) ? str :str.substring(0,index+1);

http://wiki.sdn.sap.com/wiki/display/Java/RemoveLeadingandTrailingZerosfroma+String

Regards

Ramg

Answers (3)

Answers (3)

former_member223322
Active Participant
0 Kudos

If the number of zeroes that are coming after the incoming data is always 4, then divide the incoming data by 10000 and then use the FormatNum standard function. If you are not sure with the trailing zeroes count, then you need to go for a custom UDF.

~Vaas

former_member223322
Active Participant
0 Kudos

Use the FormatNum standard function in the Arithmetic function.

~Vaas

former_member181962
Active Contributor
0 Kudos

Yes, use of FormatNum function will do the trick.

To add to Vaas' suggestion, Just mention 0 in the pattern and specify nothing the decimal separator in the properties of that function.

Regards,

Ravi

Former Member
0 Kudos

>>How is that possible?

Using a very simple UDF. Lots of example available in SDN.

Do a search.