Former Member

### Output value in decimal

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?

Best Regards,

Krish.

10|10000 characters needed characters exceeded

• Former Member
Apr 16, 2009 at 03: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

10|10000 characters needed characters exceeded
• Former Member Former Member

Hi,

No.

I have given correctly.1.000.

Regards,

Krish.

• Apr 16, 2009 at 03:46 AM

you can also use the edit mask option..

10|10000 characters needed characters exceeded
• Former Member
Apr 16, 2009 at 03: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`

10|10000 characters needed characters exceeded
• Apr 16, 2009 at 04: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

10|10000 characters needed characters exceeded
• Former Member
Apr 16, 2009 at 04: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

10|10000 characters needed characters exceeded
• Former Member Former Member

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
Apr 16, 2009 at 05: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.