In SAP ABAP, integer and numeric data types are used for numerical calculations but have key differences in terms of storage, precision, and usage.


🔢 1. Integer (I, INT1, INT2, INT4)

Example (Integer Calculation)

DATA: lv_int1 TYPE I VALUE 10,
lv_int2 TYPE I VALUE 3,
lv_result TYPE I.
lv_result = lv_int1 / lv_int2. " Normal division
WRITE: lv_result. " Output: 3 (Decimal part is removed due to integer storage)
lv_result = lv_int1 DIV lv_int2. " Integer division
WRITE: lv_result. " Output: 3

📌 Key Integer Data Types:

TypeDescriptionValue Range
IInteger (4 bytes)-2,147,483,648 to +2,147,483,647
INT1Tiny Integer (1 byte)0 to 255
INT2Small Integer (2 bytes)-32,768 to +32,767
INT4Standard Integer (4 bytes, same as I)Same as I

🔢 2. Numeric (P, F, DEC)

Example (Numeric Calculation)

DATA: lv_num1 TYPE P DECIMALS 2 VALUE 10,
lv_num2 TYPE P DECIMALS 2 VALUE 3,
lv_result TYPE P DECIMALS 2.
lv_result = lv_num1 / lv_num2.
WRITE: lv_result. " Output: 3.33 (Decimals retained)

📌 Key Numeric Data Types:

TypeDescriptionValue Range & Precision
PPacked Decimal (BCD)Up to 31 digits with decimals
FFloating Point (8 bytes)Large range with rounding errors
DECDecimal NumberSimilar to P, mainly in DDIC

🔄 Key Differences: Integer vs. Numeric

FeatureInteger (I, INT*)Numeric (P, F, DEC)
StoresWhole numbers onlyWhole + decimal numbers
MemoryFixed (1, 2, or 4 bytes)Variable (depends on precision)
PrecisionNo decimal supportSupports decimals
UsageCounting, indexing, loop countersFinancial, currency, measurements
DivisionResults in integer unless using floatRetains decimal values

🚀 When to Use What?

✅ Use Integer (I, INT*) when you need:

✅ Use Numeric (P, F) when you need:

Would you like an example of working with both in the same program? 😊