cancel
Showing results for 
Search instead for 
Did you mean: 

graphical mapping issue

Former Member
0 Kudos

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



Accepted Solutions (1)

Accepted Solutions (1)

ambrish_mishra
Active Contributor
0 Kudos

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

ambrish_mishra
Active Contributor
0 Kudos

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

Answers (4)

Answers (4)

ambrish_mishra
Active Contributor
0 Kudos

Hi Peter,

Please close the thread if your question is answered.

thanks

Ambrish

Former Member
0 Kudos

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

Former Member
0 Kudos

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

Former Member
0 Kudos

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