Application Development and Automation 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: 
Read only

Output value in decimal

Former Member
0 Likes
2,453

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.

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
Read only

awin_prabhu
Active Contributor
0 Likes
2,287

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

Read only

0 Likes
2,287

Hi,

Thanks for quick reply.

But i am getting output value 10.9, i want 109.3

please advise.

Best Regards,

Krish.

Read only

0 Likes
2,287

Check my code above.

It is giving 109.3 only.

Read only

0 Likes
2,287

Hi,

No. it is giving 10.9 only.

please advise.

Regards,

krish.

Read only

0 Likes
2,287

Check this line,

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

Read only

0 Likes
2,287

Hi,

No.

I have given correctly.1.000.

Regards,

Krish.

Read only

former_member156446
Active Contributor
0 Likes
2,287

you can also use the edit mask option..

write: l_ntwt mask '___._'

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

Read only

Former Member
0 Likes
2,287

Dear ,

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

this will solve your problem :

HR_NZ_ROUNDING_DECIMALS

Read only

Former Member
0 Likes
2,287

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

Read only

Former Member
0 Likes
2,287

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

Read only

0 Likes
2,287

Hi JK,

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

please advise.

Regards,

Krish.

Read only

0 Likes
2,287

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

Read only

0 Likes
2,287

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.

Read only

0 Likes
2,287

Hi,

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

Appreciate if provide better solution.

Regards,

Krish.

Read only

0 Likes
2,287

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

Read only

0 Likes
2,287

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

Read only

0 Likes
2,287

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

Read only

Former Member
0 Likes
2,287

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.