cancel
Showing results for 
Search instead for 
Did you mean: 

Problem with the syntax in UDF

0 Kudos

Hello SAP PI gurus

I am not a java programmer and am trying to play with it.

I want 2 integers or decimal values to be sent to UDF and in return the UDF should send the sum of those two values.


Please see the attachment for the UDF details.


When I try to activate it fails with the following error

Message was edited by: Ram Hebbalalu Source text of object Message Mapping: TRAINING_VendorToAccounts_XYZ | http://mpc.com/TrainingByRam has syntax errors: Function Total, Line 2: incompatible types found   : int required: java.lang.String return DiscountedPrice;         ^ Note: D:\usr\sap\XID\J00\j2ee\cluster\server1\.\temp\classpath_resolver\Map79c76e19b95311e5be950000002d515f\source\com\sap\xi\tf\_TRAINING_VendorToAccounts_XYZ_.java uses unchecked or unsafe operations. Note: Recompile with -Xlint:unchecked for details. 1 error

Accepted Solutions (1)

Accepted Solutions (1)

former_member184720
Active Contributor
0 Kudos

Why don't you use the standard Arithmetic "subtract" function for this?

If you want to use UDF, then change the input value type form Int to Float as you may have decimal values and use the below code.

return Float.toString(var1-var2);

0 Kudos

Thanks Hareesh

I am trying to understand using UDF since I have to use it soon.



former_member184720
Active Contributor
0 Kudos

You are trying to return an integer value and hence you are getting that error.

Just change the return statement to Integer.toString(DiscountedPrice);

but this may not handle the decimal values.

former_member186851
Active Contributor
0 Kudos

This message was moderated.

former_member184720
Active Contributor
0 Kudos

How is it different from what has been suggested?

former_member186851
Active Contributor
0 Kudos

oops sorry Hareesh,didn;t see ur UDF code below.

Answers (1)

Answers (1)

0 Kudos

Thanks Hareesh and Raghuraman

I tried both the suggestions and both worked .


Thanks a lot. I appreciate it.
Ram