on 12-23-2008 7:10 AM
Hi Everyone,
We have a scenario wherein there are 2 fields in the source structure , Quantity and Price.( Both of them are string type in Data type)
We have to multiply these and assign to target field of type string.
This causes an exception of No cast to float.
I am not aware of Java coding. Please provide me with UDF code required.
Thanks,
Vinotha M
hi ,
try this code
if (a.equals(""))
return "0";
else
return (Float.parseFloat(a))*(Float.parseFloat(b)) + "";
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Why go for a UDF when you can actually use the multiply standard function itself? Use that and avoid the UDF.
http://help.sap.com/saphelp_nw04/helpdata/en/43/c4cdfc334824478090739c04c4a249/content.htm
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
I would like to add few of my lines here...
What Vijay has said is correct, use standard function to multiply two values but make sure you are getting the correct result. The reason whay I am saying so is, most of the time standard function (Arithmatic function) gives the wrong result (in XI 3.0).
Let's say you if you multiply string 12345678 * 100 = 1234567808 (wrong result)
So in this case go for an UDF as suggested by experts in above replies.
Regards,
Sarvesh
Vinotha,
Use simple UDF not advance and pass the input values as the source fields say a and b.
and try this code
double c;
c =Double.parseDouble(a)*Double.parseDouble(b);
return ""+c;
Thanks!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Please use the following simple code for MUL.
take String a,String b,String c.
c =Double.parseDouble(a)*Double.parseDouble(b);
return c;
warm regards
mahesh.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
93 | |
10 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.