on 07-19-2013 3:54 PM
Hi Gurus
actual i have a like following input structure
<ROOT>
<NODE>
<ID>100</ID>
<VALUE>12386EUR120,00</VALUE>
</NODE>
<NODE>
<ID>200</ID>
<VALUE>ASDFGHJEUR156320,00</VALUE>
</NODE>
</ROOT>
and needed output structure is
<ROOT>
<NODE>
<WAERQ>EUR</WAERQ>
<SUMME>120,00</SUMME>
</NODE>
<NODE>
<WAERQ>USD</WAERQ>
<SUMME>156320,00</SUMME>
</NODE>
</ROOT>
how can we substract the value after currency?
Thank you
Hi Peter,
I can suggest one way:
Traverse through the string till the last character. Pick the characters from that index till the end of string. this will give you the value.
For currency, you need to get to start like above.
Traverse through the string till the last character. then pick a certain number of characters (like currency is mostly 3 characters), so pick (index -3, index)
Hope it helps!
Ambrish
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Peter,
Play around with the code below:
parameter var1
____________________________________________
int index_Value = 0;
if(var1.length() != 0)
for (int i=0; i < var1.length(); i++)
if(Character.isLetter(var1.charAt(i))&&Character.isDigit(var1.charAt(i+1))){
index_Value = i;
break;
}
return var1.substring(index_Value+1, var1.length());
____________________________________________
this gives you value.
For currency, you can twist the same code.
____________________________________________________
int index_Value = 0;
if(var1.length() != 0)
for (int i=0; i < var1.length(); i++)
if(Character.isLetter(var1.charAt(i))&&Character.isDigit(var1.charAt(i+1))){
index_Value = i;
break;
}
return var1.substring(index_Value-2, index_Value+1);
____________________________________________________
Above code will work assuming currency is always 3 characters.
Ambrish
Hi Peter,
Please close the thread if your question is answered.
thanks
Ambrish
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello,
Check this:
int len = var1[0].length();
int count =0;
for (int i = len-1; i > 0; i--)
{
if (!Character.isDigit(var1[0].charAt(i)))
{
count = i;
break;
}
}
String out = var1[0].substring(count+1, len);
result.addValue (out);
In mapping use replace string function just before this UDF and replace ","...
Thanks
Amit Srivastava
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello,
So the values will always comes like this?
<VALUE>ASDFGHJEUR156320,00</VALUE>
<VALUE>ASDFGHJUSD156320,00</VALUE>
<VALUE>ASDFGHJINR156320,00</VALUE>
or it will always be EUR?
Thanks
Amit Sriavstava
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Peter,
You can use substr function to achieve the same.
To know more about it,check the link:
http://wiki.sdn.sap.com/wiki/display/XI/Standard+Functions+in+PI+7.0
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
95 | |
11 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.