Skip to Content

Problem with the syntax in UDF

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

udf.JPG (75.0 kB)
Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • Best Answer
    Posted on Jan 12, 2016 at 06:11 PM

    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);

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jan 12, 2016 at 06:40 PM

    Thanks Hareesh and Raghuraman

    I tried both the suggestions and both worked 😊.


    Thanks a lot. I appreciate it.
    Ram

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.