‎2009 Feb 02 9:47 AM
Hi experts,
I have problem while calculating fraction value. For instance A/B = some value.
I have to print the value as it comes with 2/3 decimal values without rounding. If I deduce the length of decimal values to 2/3 in data type "Packed", it is rounding. For example it rounds 0.0995 as 0.100. But I need only 0.099 only.
If I copy the first 3 decimals in string, it is also giving problem. For example, for some divisions I am getting result as 9.955..........E-02. So, Here I could not copy the decimals to string also. So, Can u give me a solution. Is there any funtion module to get the value as it is with 2/3 decimal values.
<removed_by_moderator>
Venkat, IBM
Edited by: Julius Bussche on Feb 2, 2009 11:15 AM
‎2009 Feb 02 9:51 AM
declare it as type p decimals 3.
data : var type p decimals 3.
data : a type i value 2,
b type i value 3.
var = a / b.
write : var.
‎2009 Feb 02 9:51 AM
declare it as type p decimals 3.
data : var type p decimals 3.
data : a type i value 2,
b type i value 3.
var = a / b.
write : var.
‎2009 Feb 02 9:54 AM
If I use P with decimal 3 it is rounding some digits. Without rounding I need 3 decimals.
Venkat, IBM
‎2009 Feb 02 9:57 AM
For example it rounds 0.0995 as 0.100. But I need only 0.099 only.
This is your requirement in first post .
‎2009 Feb 02 10:07 AM
A and B values are taken from tables ( NETWR and KAWRT ) , so we can not have decimals for that and I wan to have in result only
‎2009 Feb 02 10:49 AM
>
> if you are also under crush in your organisation, do your work rather than advising all in the forum.
No, I'm neither in "Crush" nor have any crush I meant you should not use any words like U'rgent blah blah its against of forum rules.
Thanks for understanding.
Back to Topic:
>
> A and B values are taken from tables ( NETWR and KAWRT ) , so we can not have decimals for that and I wan to have in result only
So what you may do,Just store your result in type P decimal 3 type variable and print this variable.
Like:
Result type p decimal 3.
Result = NETWR / KAWRT .
print Result.
Do some work around this.
Amit.
‎2009 Feb 02 11:55 AM
Hi expert,
I already used with decimal 3. It is rounding the value which I don't want. Anyhow I tried with decimal 14, which is maximum and assigned first 3 decimal values in a string and I printed in smartform. I got solved. However, Thank you for your kindness. Thank you for your time and consideration. If I have used any hurting words, please forgive me.
Venkat
‎2009 Feb 02 12:56 PM
which is maximum and assigned first 3 decimal values in a string
and I printed in smartform. I got solved.
Yes Decimal 3 was your only concern "in resultant variable".
If I have used any hurting words, please forgive me.No need of apologies.
Also, you didn't use any offended words in your language except U'rgent in your Question Also I never mind your kind of responses.
I appreciate your learning and response.
P.S. Glad to see your problem solved though you were in urged
Cheers,
Amit.
‎2009 Feb 02 9:52 AM
Hi,
Please Test the following Sample Code May help you in this way.
data: a TYPE p DECIMALS 3,
b TYPE p DECIMALS 3,
div TYPE p DECIMALS 3.
a = 2.
b = 3.
DIV = a / b.
WRITE: div. " .667 here.Please Reply if Else Requirment.
Kind Regards,
Faisal
‎2009 Feb 02 10:09 AM
>
> Please reply immediately. I will be thankful to you if I complete this today itself. I am in urge.
Possibely,We guys also in crunch.
Venkat, IBMAlthough,rules of posting not having the instructions regarding this, But i personally believe you should not mention company name with your Signature or Name unless IBM is your Family name.
Thank you.
‎2009 Feb 02 10:23 AM
sorry sir, Your helpful tip was not the remedy for my problem. You might have got more points in forum. But none is ABAP library in the world. Anyhow thank you for your reply and if you are also under crush in your organisation, do your work rather than advising all in the forum. I am a fresher and I think there is no problem if i don't know in this new world. Anyhow I learnt a lesson from u. Thank you.
Venkat
‎2009 Feb 02 12:05 PM
I used packed data type with decimals 14, which is maximum for P and first 3 fractions I copied to string and I got the desired value, inwhich no rounding I found.
Thank you