06-26-2009 2:11 PM
Hi All,
I am facing an issue with decimals after calculation.
Below is my calculation.
l_sales_amt_round = lwa_post_data-cccur_sale +
( lwa_post_data-cccur_sale *
wa_post_data-taxper ).
Here lwa_post_data-cccur_sale has 2 decimals
wa_post_data-taxper has 3 decimals.
Result variable l_sales_amt_round of type f. ( Tried with TYPE P DECIMALS 3).
Is there any way to extract only the first 2 decimals into an amount field. I dont want this in character field.
eg: lwa_post_data-cccur_sale = 4854.00
wa_post_data-taxper = 0.175
Then l_sales_amt_round = 5.7034499999999998E+03
But when i move this to TYPE P DECIMALS 2 it is rounding to 5703.45.
But my requirement is to get 5703.44.
Is there any way to achieve this.
Thanks,
Vinod.
06-26-2009 2:59 PM
Hi Vinod,
maybe the following code snippet is helpful:
data: result type p decimals 2,
result = round( val = l_sales_amt_round dec = 2 mode = CL_ABAP_MATH=>ROUND_DOWN ).
Best regards,
Andreas
06-26-2009 2:49 PM
Isn't that what the DIV operand is for?
Check the online help for more info and examples, because I have never used it.
Kind regards, Rob Dielemans
06-26-2009 2:59 PM
Hi Vinod,
maybe the following code snippet is helpful:
data: result type p decimals 2,
result = round( val = l_sales_amt_round dec = 2 mode = CL_ABAP_MATH=>ROUND_DOWN ).
Best regards,
Andreas
06-26-2009 4:32 PM
Hi,
Thanks for the responce.
I have solved the problem on own as below.
l_sales_amt_round = ( lwa_post_data-cccur_sale *
wa_post_data-taxper ).
CLEAR l_tax_amt.
MOVE l_sales_amt_round TO l_tax_amt.
SHIFT l_tax_amt RIGHT.
SHIFT l_tax_amt RIGHT.
MOVE l_tax_amt TO l_sales_amt_round.
Here l_tax_amt is char field.
Thanks,
Vinod.