Skip to Content
avatar image
Former Member

parameters declaration

Hello ,

Why can't we declare parameters of type float .

example :

parameters flt type f.

is not allowed in abap ..Why?

Moderator message: please search for available information/documentation.

Edited by: Thomas Zloch on Feb 23, 2011 11:58 AM

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

3 Answers

  • avatar image
    Former Member
    Feb 23, 2011 at 05:47 AM

    Hi,

    Float Data Type cannot be declared in Parameters.

    If we want to use float values in our input, use packed no's or char as datatype.

    Try the following code snippets, You 'll get an idea.

    Code Snippets:

    1. PARAMETERS : A(4) TYPE P DECIMALS 2,

    B(4) TYPE P DECIMALS 2.

    DATA : C(4) TYPE P DECIMALS 2.

    C = A + B.

    WRITE : / u2018THE SUM ISu2019 , C.

    Ouput is : THE SUM IS 4,20 (Input A: 1,6, B= 2,6)

    2. PARAMETERS : A(8) TYPE c,

    B(8) TYPE C.

    DATA : C(10) TYPE C

    C = A + B.

    WRITE : 'THE SUM IS' , C.

    output: THE SUM IS 4.2 (Input A: 1.6, B= 2.6).

    <removed by moderator>

    Moderator message: do not beg for points, points removed.

    Edited by: Thomas Zloch on Feb 23, 2011 11:57 AM

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Feb 23, 2011 at 05:53 AM

    Hello Arun Prasath Kumar ,

    The point which i want to know is : why we are coding in this manner ? why can't we declare it as of float type ..?

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Feb 23, 2011 at 06:01 AM

    Hi manish,

    Since type F data is internally converted to a binary system, rounding errors can

    occur. Although the ABAP processor tries to minimize these effects, you

    should not use type F data if high accuracy is required. Instead, use type P

    data.

    You use type F fields when you need to cope with very large value ranges and

    rounding errors are not critical.

    Regards

    Seema Sharma.

    Moderator message: copy/pasted, points removed, do not repeat!

    Edited by: Thomas Zloch on Feb 23, 2011 11:56 AM

    Add comment
    10|10000 characters needed characters exceeded