cancel
Showing results for 
Search instead for 
Did you mean: 

Negative number fomrat

Former Member
0 Kudos

Hi experts,

i need you expertise in number formatting. In mapping we need to format negative as per

ex:  123,45-  need to be formatted as -00123,450 ( total length should be always 10 including - and , signs and after , 3 digits should be there

PI might receive positive numbers as wel, but only negative numbers have sign at the end.

I tried standard functions but couldn't see required output. Please help me on this

Regards,

Deep

Accepted Solutions (1)

Accepted Solutions (1)

former_member312864
Active Participant
0 Kudos

Hi,

You can use below mapping to achive this

Regards,

Former Member
0 Kudos

Hi sarojkanta,

  Thanks for you reply, But we need the format with length 10.

ex:  123,45-  need to be formatted as -00123,450 ( total length should be always 10 including - and , signs and after , 3 digits should be there

Regards,

Deep

former_member184720
Active Contributor
0 Kudos

Pass your input string to the below UDF. var1 should be your input string..

String var2,var3;

int a,b;

int c=0;

if(var1.endsWith("-"))

{

var1=var1.replace("-","");

var1="-"+var1;

c=1;

}

var2=var1.substring(0,var1.indexOf(","));

var3=var1.substring(var1.indexOf(","),var1.length());

a=var3.length();

b=var2.length();

while(a<4){

var3=var3+"0";

a++;

}

while(b<6){

var2="0"+var2;

b++;

}

if(c==1)

{

var2 = var2.replace("-","");

var2= "-"+var2;

}

return var2+ var3;

P.S.Have not tested it... Please check for the syntax errors if any..

former_member312864
Active Participant
0 Kudos

Hi ,

You can use below mapping with a simple udf

Udf is below


var1 = var1.substring(0, 😎 + "," + var1.substring(8, var1.length());

return var1;

Regards,

Former Member
0 Kudos

Thanks you very much Harish

Its worked.

Regards,

Deep

Answers (2)

Answers (2)

Former Member
0 Kudos

http://scn.sap.com/docs/DOC-51816

you can deploy this conversion exit anywhere

Former Member
0 Kudos

Hi Steve

Thanks for your reply. this has to done in PI Mapping

Former Member
0 Kudos

Hi,

You can achieve this using normal graphical mapping.

If amount endswith "-", then remove it first and use format number and concat "-" at last.

else normal format number

Former Member
0 Kudos

Format Number doesn't serve the purpose as it throws exception while formatting decimal number