Inequality between length and maximum digit count of packed decimal type causes great confusion even among seasoned developers. ABAPDOCU explains the relation with a fairly complicated formula:

Depending on the field length len and the number of decimal places dec, the following applies to the value range: (-10^(2len-1) +1) / (10^(+dec)) to (+10^(2len-1) -1) /(10^(+dec)) in increments of 10^(-dec)

Actually it’s simple: Multiply┬áthe length by 2 and you will have total digit count including decimal places and the sign. If you have a packed decimal of length 13, you are allowed 25┬ádigits for integer part and fractional part cumulated plus one place for the sign. In case you are in doubt, ABAP has a pretty nifty class to get minimum and maximum values of a numeric variable. Here is how to use it:

Leave a Reply