cancel
Showing results for 
Search instead for 
Did you mean: 

user define function-remove leading zeros

Former Member
0 Kudos

Hi All,

i want java coding for mapping function rule "remove leading zeros" early.

kindly give me response as early as possible.

regards

Peera

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Just put these 2 stateements in the UDF it will work

<b> //write your code here

String stringWithoutZeros = a.replaceFirst("^0+", "");

return(stringWithoutZeros);</b>

No need to write any thing.

Warm Regards,

Vijay

Answers (6)

Answers (6)

Former Member
0 Kudos

there is no need for an elaborate java code

As alex said use arithmetic function 'mul' and multiply the field with 1, it wud remove the leading zeroes

Vaibhav

santhosh_kumarv
Active Contributor
0 Kudos

Hi...

Try this UDF also...

public String removezero(String a,Container container)

{

int no,ans rem;

no = integer.parseint(a);

ans = no / 10;

rem = no % 10;

ans = ans + rem;

return (Integer.toString(ans));

}

Regards

Santhosh

former_member192892
Active Contributor
0 Kudos

function(String arg, Container container)

{

char[] argArr = arg.toCharArray();

int leadingZeroLen =0;

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

{

if(char<i> == '0')

{

leadingZeroLen++;

}

else

break;

}

String output = arg.substring(leadingZeroLen,arg.length());

return output;

}

Do this coding only if leading zeroes come in a character string.

If its a numeric string, then do

int argInt = Integer.parseInt(arg);

String output = ""+argInt;

return output;

Former Member
0 Kudos

Hi Mahaboob

Write UDF to parse data .

String dataVal="0230";

int parseVal = Integer.parseInt(dataVal);

System.out.println("parseVal is "+parseVal);

result.addValue(parseVal); or return parseVal;

Have a look at this thread...

http://help.sap.com/saphelp_erp2005/helpdata/en/e2/e13fcd80fe47768df001a558ed10b6/frameset.htm

http://help.sap.com/saphelp_erp2005/helpdata/en/22/e127f28b572243b4324879c6bf05a0/frameset.htm

Thanks !!!

Former Member
0 Kudos

Hi peera..

Refer this Thread..

vasanth

Former Member
0 Kudos

you dont actually need a UDF...

if you are talking about only Numeric data then you can simply use an arithmetic function and multiply by "1"

or you can use format number with ### as your entries

Message was edited by:

Alex Ong