cancel
Showing results for 
Search instead for 
Did you mean: 

Problem with UDF

abhay_aggarwal
Participant
0 Kudos

HI ,

I have lots of countryCurrency from R3 side let say 10. I want to pass only 6 from xi to target .

for this I have Wriiten the UDF.

taking input as a queue:

UDF is below

public void filterUDF(String[] curr,ResultList result,Container container){

//write your code here

for(int i=1;i<=curr.lenght();i++)

if(curr<i>.equals("USD"))

{

reuslt.addValue(curr<i>);

}

else if(curr<i>.equals("IND"))

{

reuslt.addValue(curr<i>);

}

else if(curr<i>.equals("DE"))

{

reuslt.addValue(curr<i>);

}

else

{

reuslt.addValue(ResultList.SUPPRESS);

}

}

}

when I am using this UDF I am getting the below error

Activation of the change list canceled Check result for Message Mapping Exchange_Rate_CEZH_MM | .com:ExchangeRate_CRM: Starting compilation Source code has syntax error: E:/usr/sap/XID/DVEBMGS00/j2ee/cluster/server0/./temp/classpath_resolver/Map71a412f0625311df85c8005056af4450/source/com/sap/xi/tf/_Exchange_Rate_CEZH_MM_.java:113: 'class' or 'interface' expected public static void main(String[] args) throws Exception{/!_$ClNRep_/_Exchange_Rate_CEZH_MM_ st = new /!_$ClNRep_/_Exchange_Rate_CEZH_MM_(); st.testExecute(); } ^ E:/usr/sap/XID/DVEBMGS00/j2ee/cluster/server0/./temp/classpath_resolver/Map71a412f0625311df85c8005056af4450/source/com/sap/xi/tf/_Exchange_Rate_CEZH_MM_.java:114: 'class' or 'interface' expected } ^ E:/usr/sap/XID/DVEBMGS00/j2ee/cluster/server0/./temp/classpath_resolver/Map71a412f0625311df85c8005056af4450/source/com/sap/xi/tf/_Exchange_Rate_CEZH_MM_.java:115: 'class' or 'interface' expected ^ 3 errors

IS there anything in synrax I am missing?

Regards

Accepted Solutions (1)

Accepted Solutions (1)

sbuttler77
Active Participant
0 Kudos

for(int i=1;i<=curr.lenght();i++)

if(curr.equals("USD"))

{

I think you need to add a { at the end of your for line.

abhay_aggarwal
Participant
0 Kudos

Hi Sven,

I have added { at end of line only.

Regards

sbuttler77
Active Participant
0 Kudos

Also, are you leaving out the index intentionally,


reuslt.addValue(curr);

as opposed to


reuslt.addValue(curr<i>);

Might be a typo but it should read "result" also.

Edited by: Sven Buttler on May 18, 2010 10:26 AM

abhay_aggarwal
Participant
0 Kudos

Hi ,

I have remove } from end for UDF now I am getting the another error

cannot resolve symbol symbol :

method lenght ()

location: class java.lang.String[]

for(int i=1;i<=curr.lenght();i++)

Regards

Shabarish_Nair
Active Contributor
0 Kudos

>

> Hi ,

>

> I have remove } from end for UDF now I am getting the another error

>

>

> cannot resolve symbol symbol :

> method lenght ()

> location: class java.lang.String[]

> for(int i=1;i<=curr.lenght();i++)

>

>

> Regards

its not lenght ()

it is length()

Former Member
0 Kudos

Hi,

Put this("i" is under square brackets):

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

{

if(curr[ i ].equals("USD"))

{

result.addValue(curr[ i ]);

}

else if(curr[ i ].equals("IND"))

{

result.addValue(curr[ i ] );

}

else

{

result.addValue(ResultList.SUPPRESS);

}

}

Thanks

Amit

Edited by: AmitSri on May 18, 2010 10:37 AM

Edited by: AmitSri on May 18, 2010 10:38 AM

abhay_aggarwal
Participant
0 Kudos

Hi Vijay,

I have corrected this also but still the problem is same

cannot resolve symbol

symbol : method length ()

location: class java.lang.String[]

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

^ 1 error

Regards

Shabarish_Nair
Active Contributor
0 Kudos

>

> Hi Vijay,

>

>

> I have corrected this also but still the problem is same

>

>

> cannot resolve symbol

> symbol : method length ()

> location: class java.lang.String[]

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

>

> ^ 1 error

>

>

> Regards

try curr.length;

abhay_aggarwal
Participant
0 Kudos

Hi Amit,

My req is I am getting the 10 countries currency symbol in one field I want sent to target system

only 5 countries currency symbol(IND ,USD,DIN) like this for req i am using this UDF is there anything I am missing in this UDF

This fuction

//write your code here

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

if(curr<i>.equals("USD"))

{

result.addValue(curr<i>);

}

else if(curr<i>.equals("IND"))

{

result.addValue(curr<i>);

}

else if(curr<i>.equals("DE"))

{

result.addValue(curr<i>);

}

else

{

result.addValue(ResultList.SUPPRESS);

}

giveing Mapping transformation error in MONI now

for this I took up queue when writing UDF

not value

Do I need to now do anything else in this UDF.

Regards

Edited by: Abahy Aggarwal on May 18, 2010 10:54 AM

Edited by: Abahy Aggarwal on May 18, 2010 10:55 AM

Shabarish_Nair
Active Contributor
0 Kudos
for(int i=0;i<=curr.length;i++)
if(curr<i>.equals("USD"))
{
result.addValue(curr<i>);
}
else if(curr.equals("IND"))
{
result.addValue(curr<i>);
}
else if(curr.equals("DE"))
{
result.addValue(curr<i>);
}
else
{
result.addValue(ResultList.SUPPRESS);
}

you code needs some correction as above.

abhay_aggarwal
Participant
0 Kudos

Hi Vijay,

I did the changes as you told but still below error is there in MONI

Runtime exception during processing target field mapping /ns0:Exchange_Rate_CEZH_Receiver_MT/item/TCURR. The message is: Exception:[java.lang.ArrayIndexOutOfBoundsException: 3] in class com.sap.xi.tf._Exchange_Rate_CEZH_MM_ method filterUDF$[] at

sbuttler77
Active Participant
0 Kudos

else if(curr.equals("IND"))

this needs to be

 
else if(curr<i>.equals("IND"))

etc

PS this being said its outrageous XI still doesn't have syntax checking integrated.

Edited by: Sven Buttler on May 18, 2010 11:30 AM

abhay_aggarwal
Participant
0 Kudos

Hi,

//write your code here

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

if(curr.equals("USD"))

{

result.addValue(curr<i>);

}

else if(curr.equals("IND"))

{

result.addValue(curr<i>);

}

else if(curr.equals("DE"))

{

result.addValue(curr<i>);

}

else

{

result.addValue(ResultList.SUPPRESS);

}

I have changed UDF like this withoutcurr<i>

and now it is not showing any error in MONI but when I send the message with USD and TTT currenices

both are not coming in output

PS.

According to UDF if USD,IND,DE is there they should be populated in payload. exclding these symbol nothing should populated

Please advice.

Regards

sbuttler77
Active Participant
0 Kudos

Are you actually reading what others are writing?!

Shabarish_Nair
Active Contributor
0 Kudos
for(int i=0;i<curr.length;i++)
{
	if(curr<i>.equals("USD"))
	{
	result.addValue(curr<i>);
	}
	else if(curr<i>.equals("IND"))
	{
	result.addValue(curr<i>);
	}
	else if(curr<i>.equals("DE"))
	{
	result.addValue(curr<i>);
	}
	else
	{
    result.addValue(ResultList.SUPPRESS);
	}
}

use this code. this works for me so it sud for you too.

Also, in case you find issues, it would also be a good idea to get yourself used to java coding.

There are various tutorials available (google it)

Happy learning.

abhay_aggarwal
Participant
0 Kudos

Hi Vijay,

It worked for me also .

Sure I willl start working on it .

Can you please suggest me any link in which I can learn how to work with UDF .

Thanks & Regards

Answers (0)