Skip to Content
avatar image
Former Member

Issues with Type P supporting only 16 field length

Hi Experts,

I am facing an issue where I am trying to do a perform the below calculation on a type P variable. Please note that this is a code in a FM whose one of changing parameters is l_amount, and , l_amount is type CHAR30

DATA: tmp TYPE p DECIMALS 2,

shift TYPE i.

tmp = c_amount * 10 ** shift.

l_amount = tmp.

Shift will have value of decimal places to shift . However I want more than 17 digits before decimal and 2 decimal places. However right now it is dumping.

I have tried using LONG_CURR but the rounding off is getting wierd . For example a value like 12345678901234567.34 is getting converted to 12345678901234567.20 if shift is = 0.

Please help. We are at SAP Netweaver 7.0 .

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

3 Answers

  • Best Answer
    Jun 23, 2011 at 06:17 AM

    Hi.,

    You can use field length ., try like this.,

    DATA: tmp(20) TYPE p DECIMALS 2,

    shift TYPE i.

    else create a data element with DEC or QUAN type with length and decimal what ever you required.

    and assign tmp. to that data element., like

    date tmp type zde_temp., " zde_temp is the data type which you created

    hope this helps u.,

    Thanks & Regards,

    Kiran

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Jun 22, 2011 at 08:40 PM

    Hello Ashish Kumar ,

    Based on your requirement you can use the below mentioned SAP standard data types (both two decimals and 3 decimals with more than 17 digits before decimal) as the reference for your variables inside your program logic.

    DEC23_2

    OIUH_DEC18_2

    OIUH_DEC22_2

    /SDF/DEC30_3

    hope this answers your question.

    Thanks,

    Greetson

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      Hello Ashish Kumar ,

      I am in the assumption that you want the results to be upto more than 17 characters long before decimal and decimal should be 2 places. that is the reason I highlighted those data elements.

      I am not clear what you are trying to achieve then????

      Can you explain in detail your requirement.

      Thanks,

      Greetson

  • avatar image
    Former Member
    Jun 28, 2011 at 05:58 PM

    Type p (packed decimal) is always stored in 8 bytes in the database. Therefore, you usually see usage field(15) type p decimals n, since the last bits are for the sign, and the decimal is, of course, implied and shown in the display based upon your definition of the p field. Considering that we can store two digits per byte, this gives us a maximum of 15 digits plus the sign in any p field.

    Add comment
    10|10000 characters needed characters exceeded