on 12-11-2013 10:28 AM
Hi Experts ,
I am looking for a UDF to write a code so that i can get the value for the total sales amount below is the logic
Case 1 :
Total Sales amount = (Extended Amount)-(Deposit amount)-(Tax Amount)
Case 2:
and if any discount comes for an Item (Discount against the Price of the item) then the Sales amount value should be calculated as below
Sales Amount = (Extended Amount+Discount )- (Deposit Amount)- (Tax Amount)
How can i achieve this by using UDF . If i use graphical mapping I am concerned with the exception that occurs if no values are present in the Source Input fields while calculating using Arithmetic functions in the Graphical mapping .
So i guess Using UDF might resolve this problem ... Please help me out achieve this above logic using UDF .
Regards,
Khan
Hello Aziz,
You can use mapWithDefault[0] to set the value to 0 when the field is not present. So, this is very much possible without UDF. So the mapping would be:
ExtendedAmount -> mapWithDefault [0] -> add logic and so on....
Hope this helps,
Mark
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Mark,
Thanks for the quick reply ,
Let me tell you one thing . The field names are of Type decimal ie
Sales Amount = (Extended Amount+Discount )- (Deposit Amount)- (Tax Amount)
Field names Type
--------------------------------------
Extended amount String
Discount decimal
Tax amount decimal
deposit amount decimal
When i try to using Add function
ExtendedAmount -> mapWithDefault [0] -> add--> Result
i am getting error
Exception:[com.sap.aii.mappingtool.tf7.FunctionException: Cannot cast '' to decimal number] in class com.sap.aii.mappingtool.flib7.Arithm method add[, 2.40, com.sap.aii.mappingtool.tf7.rt.Context@7ece276f] See error logs for details
Hi Mark,
When i use MapwithDefault[0] as per your suggestion . I am still getting the same error if Source Input field is empty or null . see my mapping below and suggest a solution
case 1 : if all the source field values exist i am able to get the result successfully without any error.
mapping runs fine
Case 2 : If any of the source fields for example Amount = 0 or does not exist then i get the exception even after using MapWithDefault[0] .
Error :
Please help me to resolve this .
Hi Aziz,
The error is because you are giving input string/char to airthmetic function.
Please try to perform below check before input to airthmatic function.
Input --> mapWithDefault (blank) --> equal --> Blank (constant) --> Not (Boolean function)
then perforn the airthmatic operation.
If you do not want to perform this many validation in graphical mapping the use the UDF.
Regards,
Harish
User | Count |
---|---|
78 | |
10 | |
9 | |
7 | |
6 | |
6 | |
5 | |
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.