cancel
Showing results for 
Search instead for 
Did you mean: 

how to remove leading spaces SAP PI between negative sign and values

Former Member
0 Kudos

HI Team ,

I have a scenario where the input is coming as

<IndividualRevenueForCRE>2.00-</IndividualRevenueForCRE>

After doing the mapping of removing the negative sign from suffix and putting in profix using the code

if(a.indexOf("-") > 0)

{

return ("-" + a.substring(0,a.indexOf("-")) );

}

else

{return a;}

I am getting this output in the mapping as

<Value>-2.00</Value>

But when I am checking in MONI i am seeing a space between negative sign and value

<Value>- 2.00</Value>


And while coming in the file it is coming like

-            2.00


because of this it is failing in the target system , can anyone help in how to overcome this issue ?

Accepted Solutions (0)

Answers (2)

Answers (2)

former_member184720
Active Contributor
0 Kudos

Try adding a trim and observe the behavior

return ("-" + a.substring(0,a.indexOf("-")).trim());

Former Member
0 Kudos

Hi Hareesh ,

Thanks for the suggestion , but this approach is not working

former_member184720
Active Contributor
0 Kudos

>>> Thanks for the suggestion , but this approach is not working

Are you sure if they are just spaces? Download the payload and see if you are receiving any spl char?

if they are spaces, then trim should work.

RaghuVamseedhar
Active Contributor
0 Kudos

Abhishek,

You can archive this without UDF.

Use standard functions 'endsWith', 'replaceString' and then 'concat'.

Replace - with "" and then concat - at the beginning of string (If input ends with -).