cancel
Showing results for 
Search instead for 
Did you mean: 

Concatenate Problem

Former Member
0 Kudos

Hi,

My input is in this format. NODE is 0...unbounded

<Taxes>

<Tax TaxCode="US2" Amount="30.20" CurrencyCode="USD" DecimalPlaces="2" />

<Tax TaxCode="XY" Amount="7.00" CurrencyCode="USD" DecimalPlaces="2" />

<Tax TaxCode="XA" Amount="5.00" CurrencyCode="USD" DecimalPlaces="2" />

<Tax TaxCode="AY" Amount="5.00" CurrencyCode="USD" DecimalPlaces="2" />

<Tax TaxCode="XD" Amount="24.44" CurrencyCode="USD" DecimalPlaces="2" />

<Tax TaxCode="UK" Amount="21.83" CurrencyCode="USD" DecimalPlaces="2" />

<Tax TaxCode="XF" Amount="9.00" CurrencyCode="USD" DecimalPlaces="2" />

</Taxes>

My Target should be in this format.

Tax code = US2,XY,XA,,AY,XD,UK,XF

I need to write an UDF for this.

Thanks

Vikranth Khimavath

Accepted Solutions (1)

Accepted Solutions (1)

0 Kudos

Hi Khimavath,

Pass the context in the UDF with one input of Tax code and inside UDF write following code:

String s = a[0];

for(int i=1;i<a.length;i++)

{

s= s + "," + a<i>;

}

result.addValue(s);

This will meet your requirement.

Regards,

Amit.

Edited by: Amit Valecha on Dec 20, 2007 2:26 PM

Former Member
0 Kudos

Hi Amit,

i written the below code but iam getting some error

*Java:256: cannot resolve symbol symbol : class string location: class com.sap.xi.tf._OTA_AirLowFareSearchRS_To_Z_SDS_TP_AVAILABILITY_Response_MM_V001_NEW_ string s = a[0];

^ 1 error*

Thanks

Vikranth Khimavath

0 Kudos

Hey khimavath,

Just copy paste the following code:

java.lang.String str =a[0];

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

str = str + "," + a<i>;

result.addValue(str);

Just make a little change in above code that inside for loop write a with index i in square braces I am not able to do dat coz its used for highlighting links while posting.

I have tried it myself,It would solve your problem.

Cheers,

Amit.

Edited by: Amit Valecha on Dec 20, 2007 3:26 PM

Answers (2)

Answers (2)

Former Member
0 Kudos

>java.lang.String s = a[0];

>for(int i =1; i<a.length; i++)

>{

>s = s + a<i>;

>}

>result.addValue(s);

This shud do your job.THe statement inside the for loop is

s = s plus a(i)( use square brackets)

Thanks and regards

Hari

Reward if useful.

Edited by: Sreehari Nambiar on Dec 20, 2007 11:13 AM

aashish_sinha
Active Contributor
0 Kudos

Hi,

Use multiple concat in graphical mapping to map the output to Tax code.

use concat and drag the first input US2 to the first location and give "," for the other input and then same thing once again. in other input put the output of first concat and then "," in other and finally map it to Tax Code.

Like this XA,,AY,XD,UK,XF

Concat input 1 Input 2 Result

US2 , US2,

US2, XY US2,XY

US2,XY , US2,XY,

........................................

similarlty till last one and output to TAx code the target valur.

Hope this will help you.

Regards

Aashish Sinha

PS : reward points if helpful