Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

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


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 .

Former Member

Hi Ashish Kumar,

There is a rule called calculation type , which is very important for defining how ABAP arithmetic expressions are performed (refer to the ABAP doc, word "calculation type"): as you use **, the ABAP runtime environment uses a calculation type Floating point, and so it converts the packed number to float. Floating point numbers have a limited number of significant digits (around 17 as you could see), the least significant are lost. (note that there are new data types in 7.02). The solution is quite simple, you use the biggest possible packed number PSHIFT = 10 ** shift, and then tmp = c_amount * PSHIFT.

Hi DaveL,

Type p (packed decimal) is always stored in 8 bytes in the database.

I think there would be big issues in SAP systems as packed fields with more than 15 digits are often used...


0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question