on 08-22-2008 4:35 AM
Hi,
The value coming from Idoc at source side is 6,999,432.08.
I want the value to be passed at target side as 6,999,432
I do not want .08
How i will do the message mapping. Can someone help me out.
Thanks,
Hi Ashish
First use airthmatic function Round so that ur value becomes 2,520,926 then use Format Number function with 000,000,000.00.
Regards
Raj
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Ashish,
I have created a UDF with input a and entered the following code in the UDF
-
BigDecimal n = new BigDecimal(a);
// public static int ROUND_FLOOR 3; from java.math.* constants
int ROUND_FLOOR = 3;
// strip decimals with round to floor at zero precision
n = n.setScale(0,ROUND_FLOOR);
// return to 2 decimals precision
return n.setScale(2,3).toString();
-
Then map field_in --> UDF --> field_out
We believe that once a number reaches a certain magnitude the float precision is lost giving us the unpredictable results.
So we have used the BigDecimal format which guarantees precision.
Regards,
Mike
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Ashish,
I have tested this and all works as you expect. I have also provided two examples due to confusion as to whether you want the decimal places. You stated in an earlier post 'I do not want .08, i want .00' but in your last post that 'Source Value be 22345.45 or 22345.78 or 22345.99.........target value should be 22345'
Two decimal places .00
LHS field_in --> floor (arithmetic function) to give you the integer value required (rounded down) --> format number (second arithmetic function and indicate a format of 0.00 to represent two decimal places) --> RHS field_out
Source Target
22345.45 22345.00
22345.78 22345.00
22345.99 22345.00
No decimal places (integer)
LHS field_in --> floor (arithmetic function) to give you the integer value required (rounded down) --> RHS field_out
Source Target
22345.45 22345
22345.78 22345
22345.99 22345
I hope this clears up your issue
Regards,
Mike
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi
Mike
thanks for reply ........
Using only floor function i faced the issues :
if source value is 4448601.75....then target value is 4448602......i want 4448601
if source value is 999999.99....then target value is 1000000......i want 999999
For many such values, this logic does not work.
Thanks,
Ashish
Hi,
The value coming from Idoc at source side is 6,999,432.08.
I want the value to be passed at target side as 6,999,432
I do not want .08
and for value 6,999,432.45, 6,999,432.49, 6,999,432.50, 6,999,432.51, 6,999,432.99..........i want the value to be passed at target side as 6,999,432
How i will do the message mapping. Can someone help me out.
Thanks,
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
HI
If i use Round Function then for value 2,520,921.26, the output is 2,520,922
If i use Ceil Function then for value 2,520,921.26, the output is 2,520,922
If i use Floor Function then for value 2,520,921.75, the output is 2,520,922
If i use Format Number function with Number Format as 000000 then for value 2,520,921.50, the output is 2,520,922
For any source value like 2,520,921.01, 2,520,921.20, 2,520,921.35, 2,520,921.75, 2,520,921.88, 2,520,921.99.....I want the output as 2,520,921
Can anyone help me on this
Ok, then select either the round, floor or ceiling arithmetic function to give you the integer value required (rounded up or down)
Then you could add a second arithmetic function 'format number' and indicate a format of 0.00 to represent two decimal places
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
In your message mapping, apply the arithmetic function ROUND and this will return 926 (instead of 926.08
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
81 | |
10 | |
10 | |
9 | |
7 | |
6 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.