Skip to Content
avatar image
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?

Please advise.

Best Regards,

Krish.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

6 Answers

  • avatar image
    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

    Add comment
    10|10000 characters needed characters exceeded

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

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    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

    Add comment
    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

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    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

    Add comment
    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

  • avatar image
    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.

    Add comment
    10|10000 characters needed characters exceeded