SAPFree referencePDF, Excel, Word exportSAP ABAP

ABAP Built-in Data Types Reference

Choosing between type C, N, STRING, I and P is a daily decision in ABAP, and the wrong choice causes truncation, lost leading zeros or rounding errors. This reference lists the predefined ABAP types with their length, initial value and the situation each one is meant for.

Download:
TypeMeaningLengthInitial valueTypical use
C
Character
1 to 65535 characters, default 1
Blanks
Short fixed-length text, flags, codes
N
Numeric text
1 to 65535 digits, default 1
All zeros
Number strings with leading zeros such as document numbers
D
Date
8 characters, format YYYYMMDD
00000000
Calendar dates
T
Time
6 characters, format HHMMSS
000000
Time of day
X
Byte (hexadecimal)
1 to 65535 bytes, default 1
Hex zeros
Raw bytes, bit flags
I
Integer
4 bytes, -2147483648 to 2147483647
0
Counters, indexes, loop variables
INT8
8-byte integer
8 bytes
0
Very large counts, timestamps in numeric form
B (INT1)
1-byte integer
1 byte, 0 to 255
0
Small codes, DDIC type INT1
S (INT2)
2-byte integer
2 bytes, -32768 to 32767
0
Small counters, DDIC type INT2
P
Packed number
1 to 16 bytes, default 8, up to 31 digits, 0 to 14 decimals
0
Quantities and amounts needing exact decimals
F
Binary floating point
8 bytes
0
Scientific calculation where rounding error is acceptable
DECFLOAT16
Decimal floating point, 16 digits
8 bytes
0
Exact decimal arithmetic with a wide exponent range
DECFLOAT34
Decimal floating point, 34 digits
16 bytes
0
High-precision decimal arithmetic
STRING
Variable-length character string
Dynamic, no fixed limit
Empty string
Free text, JSON, XML, concatenation
XSTRING
Variable-length byte string
Dynamic, no fixed limit
Empty byte string
Binary data, files, attachments
UTCLONG
Time stamp with 100 nanosecond resolution
8 bytes
Zero time stamp
Precise UTC time stamps in newer releases

Availability of INT8, DECFLOAT and UTCLONG depends on your NetWeaver or S/4HANA release. Check with the ABAP keyword documentation (transaction ABAPDOCU) for your system.

Custom ABAP review before S/4HANA

Optional: a conversation about reviewing custom code for migration readiness with a private, on-prem AI assistant.

Optional. The tool and every export work without this. No spam.

How to use this reference

Search by type letter or by use, for example packed or date. Each row gives the length rules, the initial value you get after CLEAR or on declaration, and a typical use. Use the initial value column to predict what an uninitialised variable holds, because tests such as IF var IS INITIAL depend on it. Export the table when you need a handout for new developers or a coding standard appendix.

Character, numeric text and strings

Type C is fixed length and pads with blanks, so trailing spaces are not significant in comparisons. Type N holds digits as characters and keeps leading zeros, which is why material and document numbers are often type N. STRING grows as needed and is the best choice for free text and generated output. Use fixed-length C for fields that map to database columns, and STRING for working variables where the length is unknown.

Numbers: I, P, F and DECFLOAT

Use I for counters and indexes. Use P with the DECIMALS addition for money and quantities, because packed numbers are exact in decimal arithmetic. Type F is binary floating point and cannot represent many decimal fractions exactly, so avoid it for amounts. DECFLOAT16 and DECFLOAT34 give decimal floating point when you need a large range with exact decimal digits. Mixing types in one expression triggers implicit conversions, so declare variables with the types of the data they receive.

Common mistakes

A frequent bug is moving a long value into a short type C field, which truncates silently. Another is comparing a type N value to a type C literal without allowing for leading zeros, or forgetting that a type P field needs DECIMALS or it holds only whole numbers. Dates and times are character-like, so arithmetic on type D works in days but is only safe with valid dates. Prefer typing from the data dictionary with TYPE and data elements rather than hard-coding C lengths.

Frequently Asked Questions

What is the difference between type C and type STRING?

Type C has a fixed length and is padded with blanks, while STRING is dynamic and has no fixed length. C suits database-mapped fields and short codes. STRING suits free text, concatenation, JSON and XML where the length varies and trailing blanks might matter.

Why does type N keep leading zeros?

Type N is a character field restricted to digits, so it stores each digit as a character and pads the left with zeros. That is why document and material numbers are often type N. Conversion exits such as ALPHA add or remove those zeros for display.

Should I use type P or type F for money?

Use type P, usually through a currency amount data element such as one with domain type CURR. Packed numbers do exact decimal arithmetic. Type F is binary floating point and can produce small rounding differences that are unacceptable in financial calculations.

What is the initial value of a date variable?

The initial value of type D is 00000000, which is not a valid calendar date, and the initial value of type T is 000000. Test with IS INITIAL rather than comparing to a literal, and validate dates before doing arithmetic on them.

If your team is modernising custom ABAP code before a move to S/4HANA, Netray can discuss how AI-assisted code review can run privately against your own repository.