Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Type P (Packed Number) Specifications ?

ibrahim_u
Active Participant
0 Likes
50,113

Hi Experts,

Are there any document to get detailed information about data types especially type P (Packed) data types.

5 REPLIES 5
Read only

dani_mn
Active Contributor
0 Likes
18,426

HI,

check this information about data types.

   Type      Description             DL     Initial value 

    C     Character                  1      Space 
    N     Numeric text               1      '00...0' 
    D     Date YYYYMMDD              8      '00000000' 
    T     Time HHMMSS                6      '000000' 
    X     Byte (heXadecimal)         1      X'00' 
    I     Integer                    4      0 
    P     Packed number              8      0 
    F     Floating point number      8      '0.0' 
  STRING  String                  variable  empty string 
XSTRING  Byte sequence (X string) variable  empty X string

Regards,

Read only

gopi_narendra
Active Contributor
0 Likes
18,426

The valid length for packed numbers is between 1 and 16 bytes; two decimal places are packed into one byte, whereby the last byte only contains one place and the plus/minus sign; after the decimal separator, up to 14 decimal places are permitted. Depending on the field length len and the number of decimal places dec, the following applies for the value area: (-10(2len -1) +1) / (10(dec)) to (10(2len -1) -1) /(10(+dec)) in steps of 10^(-dec). Values in between this range are rounded off.

fractional portion

Fractional portions contain the fractional part of a number and are noted independent of the number system to the right of the separator. These are the decimal places (for decimal numbers) that come after the decimal separator.

Regards

- Gopi

Read only

Former Member
0 Likes
18,426

Hi:

There are two main categories of data in ABAP/4: character and numeric.

Integers, Packed decimals and floating point are Numeric data types -

<b>Packed Decimal</b>: Packed decimal values are stored two digits per byte. The end byte is an exception; it stores a single digit and the sign. The decimal point is not stored and so does not take up any space in the field; it is part of the definition.

Floating point: Floating-point variables are always approximate. They can be used for calculations requiring very large values or many decimal places. Precision up to 15 decimal places is possible, but this is hardware-dependent. In floating-point variables, the exponent is also signed.

Integers: Use integers for variables that will be involved in simple computations or when no decimal points are required. Variables such as counters, indexes, positions, or offsets are good examples.

A decimal variable stores (L*2)-1 digits, where L is the length of the variable in bytes. Decimal values are stored two digits per byte, except the end byte, which contains a single digit and a sign. The decimal point itself is not stored; it is an attribute of the definition. For example, data f1(4) type p defines a variable f1 that is four bytes long and can hold seven digits (plus a sign), as shown in Figure 7.2. data f2(3) type p decimals 2 defines a variable f2 that is three bytes long and can hold five digits (plus a sign). The definition data f3 type p defines a variable f3 capable of holding 15 digits because the default length for type p is 8.

Regards,

Sookshma.

Read only

Former Member
18,426

Hi Ibrahim!

The length of packed numbers (type p) is given in bytes. Each decimal digit is represented by a half-byte. The last half-byte is reserved for the sign. The maximum number of decimal places is the length of the number minus 1 (that is, there must be at least one digit before the comma).

So if you declare

1)

data p1(2) type p.

then the possible value range will be [-999 to 999];

2)

data p1(2) type p decimals 2.

then the possible value range will be [-9.99 to 9.99].

Regards,

Pavel Aleshko

Read only

Former Member
0 Likes
18,426

Hi,

Check the link below

http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb2fd9358411d1829f0000e829fbfe/content.htm

http://abap4.ru/doc/1/types.htm

ABAP/4 Data Type

In ABAP/4, we can declare data by command DATA.

Type Description Initial Value

C Character Space

D Date ’00000000’

F Floating Point 0.0

I Integer 0

N Numeric Text ’0’

P Packed Decimal 0

T Time ’000000’

X Hexadecimals X00

  • Packed numbers - type P

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. 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.

You can use type P data for such values as distances, weights, amounts of money, and so on.