Home > ABAP > ABAP Predefined Data Type P

ABAP Predefined Data Type P

September 12th, 2009 Leave a comment Go to comments

Type p means packed number. This type always used for accuracy calculation for distances, weights, amounts of money, and so on.

Type P data allows digits after the decimal point. The number of decimal places is generic, and is determined in the program. The value range of type P data depends on its size and the number of digits after the decimal point. The valid size can be any value from 1 to 16 bytes.Tge default size is 8, if you do not specify the length in the program. Two decimal digits are packed into one byte, while the last byte contains one digit and the sign. Up to 14 digits are allowed after the decimal point. The initial value is zero. When working with type P data, it is a good idea to set the program attribute Fixed point arithmetic.Otherwise, type P numbers are treated as integers.

DATA: lv_qty TYPE p DECIMALS 3.
 
lv_qty = '23.232'.

The hex format for lv_qty in memory is ’000000000023232C’. The character ‘C’ means the positive number while ‘D’ represents the negative number.

In the ABAP dictionary, there are several dictionary data types like DEC,CURR,QUAN. The converiosn rule between type P in ABAP language and above data type in ABAP dictionary is (n+1)/2. That is to say, if we have an data element with length 13 and decimal 3, it is the same like below data definition in ABAP program.

DATA: lv_qty(7) TYPE p DECIMALS 3.
  1. No comments yet.
  1. No trackbacks yet.