cancel
Showing results for 
Search instead for 
Did you mean: 

Message Mapping : conversion of source value 2,520,926.08 to 2,520,926

Former Member
0 Kudos

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,

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

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

Answers (5)

Answers (5)

Former Member
0 Kudos

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

Former Member
0 Kudos

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

Former Member
0 Kudos

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

Former Member
0 Kudos

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,

Former Member
0 Kudos

Hi,

As mentioned in above posts, you need to use the ROUND function to remove those decimal values.

Or even you can use the FormatNumber ...where don't consider the decimal places, that will also work

Thanks

Swarup

Former Member
0 Kudos

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

Former Member
0 Kudos

Hi Ashish,

Map the source to Format Number and just type all ###########.

Now you will not get the zeros.

Thanks,

Srini

Former Member
0 Kudos

Hi,

can anyone help me to write UDF for it...

Source Value be 22345.45 or 22345.78 or 22345.99.........target value should be 22345.

thanks,

Former Member
0 Kudos

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

Former Member
0 Kudos

In your message mapping, apply the arithmetic function ROUND and this will return 926 (instead of 926.08

Former Member
0 Kudos

Thanks for your reply

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.00

I do not want .08, i want .00

How i will do that..??.