04-16-2009 4:38 AM
Hi All,
I want to print decimal point as well.
sample code as below.
l_ntwt = lips-ntgew / lips-lfimg.
suppose lips-ntgew = 109.300 and lips-lfimg = 1.000
I want output as l_ntwt = 109.3
How to do this?
Please advise.
Best Regards,
Krish.
04-16-2009 4:43 AM
Hi,
Declare 'l_ntwt' like below.
Report ZTEST.
DATA: lips_ntgew TYPE p DECIMALS 3,
lips_lfimg TYPE p DECIMALS 3,
l_ntwt TYPE p DECIMALS 1. <------ Like this
lips_ntgew = '109.300'.
lips_lfimg = '1.000'.
l_ntwt = lips_ntgew / lips_lfimg.
WRITE:/ l_ntwt.
Edited by: Sap Fan on Apr 16, 2009 5:43 AM
Edited by: Sap Fan on Apr 16, 2009 5:44 AM
04-16-2009 4:46 AM
Hi,
Thanks for quick reply.
But i am getting output value 10.9, i want 109.3
please advise.
Best Regards,
Krish.
04-16-2009 4:50 AM
04-16-2009 4:54 AM
04-16-2009 5:06 AM
Check this line,
lips_lfimg = '1.000'. <-- U might have given '10.000'
04-16-2009 5:08 AM
04-16-2009 4:46 AM
you can also use the edit mask option..
write: l_ntwt mask '___._'
read the help for edit mask.. it will tell you more..
04-16-2009 4:50 AM
Dear ,
No need to do anything use a simpllly a Function module for this ;
this will solve your problem :
HR_NZ_ROUNDING_DECIMALS
04-16-2009 5:11 AM
hi
l_ntwt = lips-ntgew / lips-lfimg.
suppose lips-ntgew = 109.300 and lips-lfimg = 1.000
l_ntwt = l_ntwt / 100.
I want output as l_ntwt = 109.3
so u will get exact result ...
~linganna
04-16-2009 5:13 AM
Hi,
try this
data: l_ntwt type p decimals 1,
lips_ntgew type p decimals 3 value '109.300',
lips_lfimg type p decimals 3 value '1.000'.
l_ntwt = lips_ntgew / lips_lfimg.
write:/ l_ntwt.
o/p : 109.3
04-16-2009 5:16 AM
Hi JK,
I tried this.But o/p is displaying as 10.9
please advise.
Regards,
Krish.
04-16-2009 5:18 AM
04-16-2009 5:27 AM
Try using 'Write To'.
Report ZTEST.
DATA: lips_ntgew TYPE p DECIMALS 3,
lips_lfimg TYPE p DECIMALS 3,
l_ntwt TYPE p DECIMALS 1,
ss(5) type c.
lips_ntgew = '109.300'.
lips_lfimg = '1.000'.
l_ntwt = lips_ntgew / lips_lfimg.
WRITE l_ntwt TO ss.
WRITE:/ ss.
04-16-2009 5:52 AM
Hi,
Sorry.no use.i don't know i am getting ouptut 10.9.
Appreciate if provide better solution.
Regards,
Krish.
04-16-2009 5:58 AM
Put a brekpoint on the line 'l_ntwt = lips_ntgew / lips_lfimg' and see what is getting populated in the field 'l_ntwt'.
04-16-2009 6:02 AM
With the same piece of code I am getting the desired output,debug once and check why you are getiing so?
04-16-2009 6:06 AM
Hi,
Use Packed decimal type data type.
You want single decimal so declare your variable like.
Data: Var type p decimals 1.
This can print your output with the same way you want.
Regards,
Himanshu
04-16-2009 6:47 AM
The problem is in Program attributes there is a check mark called Fixed point arithmetic.Have to check enabled.
Problem solved.
Thanks alot for the quick replies.