Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Output value in decimal

Former Member
0 Kudos

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.

18 REPLIES 18

awin_prabhu
Active Contributor
0 Kudos

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

0 Kudos

Hi,

Thanks for quick reply.

But i am getting output value 10.9, i want 109.3

please advise.

Best Regards,

Krish.

0 Kudos

Check my code above.

It is giving 109.3 only.

0 Kudos

Hi,

No. it is giving 10.9 only.

please advise.

Regards,

krish.

0 Kudos

Check this line,

lips_lfimg = '1.000'. <-- U might have given '10.000'

0 Kudos

Hi,

No.

I have given correctly.1.000.

Regards,

Krish.

former_member156446
Active Contributor
0 Kudos

you can also use the edit mask option..

write: l_ntwt mask '___._'

read the help for edit mask.. it will tell you more..

Former Member
0 Kudos

Dear ,

No need to do anything use a simpllly a Function module for this ;

this will solve your problem :

HR_NZ_ROUNDING_DECIMALS

Former Member
0 Kudos

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

Former Member
0 Kudos

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

0 Kudos

Hi JK,

I tried this.But o/p is displaying as 10.9

please advise.

Regards,

Krish.

0 Kudos

hit F1 on write statement... and try to move the data...

0 Kudos

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.

0 Kudos

Hi,

Sorry.no use.i don't know i am getting ouptut 10.9.

Appreciate if provide better solution.

Regards,

Krish.

0 Kudos

Put a brekpoint on the line 'l_ntwt = lips_ntgew / lips_lfimg' and see what is getting populated in the field 'l_ntwt'.

0 Kudos

With the same piece of code I am getting the desired output,debug once and check why you are getiing so?

0 Kudos

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

Former Member
0 Kudos

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.