cancel
Showing results for 
Search instead for 
Did you mean: 

Remove Zero Padding

Former Member
0 Kudos

How can i do this?.

Do we have stanadard function?.

If data is numeric, what i need to do?.

If data is string, what i need to do?.

Accepted Solutions (0)

Answers (4)

Answers (4)

Former Member
0 Kudos

Rahul,

You cannot achieve this with standard functions. You have to go for User defined function.

Put this code in your UDF:

Name the function as <b>zerosuppress</b> and take the <b>cache as value</b> and take <b>one argument input</b>. Then put the code below:

//write your code here

String output = input.replaceFirst("^0+","");

return output;

This removes all the leading zeros.

---Satish

Former Member
0 Kudos

Hi Rahul,

U can do it using graphical mapping.

Use <b>abs </b>function from <b>arithmetic</b> group.

It works for both string and integer.

but use only for +ve numbers.

Thanks,

Maheshwari.

Former Member
0 Kudos

Hi,

With the UDF we can also achieve ,plz try to see the below

Suppouse you received the format "000123" then you want 123.

1)One way is input Sting{} num

in UDF

int actval = Integer.parseInt(num.trim());

return actval;

OR

input num as string array list and try to maitain the logic to get the char which is not zero

String{} num.

String{} actval = "".

for(int i = 0 ; i < num.length ;i++){

if (! num(i).equals("0"))

actval = actval + num(i);

}

return actval;

I am sure first one will work.

Regards

Chilla

Former Member
0 Kudos

HI,

try also,

Create a user defined funciton zerosuppress and take the cache as value and take one argument input. Then put the code below:

//write your code here

String output = input.replaceFirst("^0+","");

return output;

It will remove all your leading zeros. Let me know whether your issue is resolved or not?

Regrds

Chilla

Former Member
0 Kudos

HI,

see this can be possible wih standard functions

FormatNum

Converts I according to a pattern that you define using the function properties. The possible patterns are the same as in the

http://help.sap.com/saphelp_nw04s/helpdata/en/43/c4cdfc334824478090739c04c4a249/content.htm

And User defined functions also.

You can write auser defined function to achieve this

Regards

Chilla