ABAP Core Part 3: Data Types and Literals
Preview · a free account unlocks the full lesson
Know ABAP's built-in types — character, numeric, date/time, string and packed — how literals work, where lengths and decimals matter, and which type to choose for business data.
In this lessonShow sectionsHide sections
Visual overview
Explanation
Part 2 covered declaring variables in general. Now the question is which type to actually use, and what happens with literals.
Among the character-like types, c LENGTH n is fixed length and padded with blanks, and most dictionary fields — an airline code, a name — are declared as c. n LENGTH n holds digits only, including leading zeros, which suits document numbers like '0000004711', though it isn't meant for calculations. string is variable length and is ideal for text built up at runtime. Character types: c (fixed length), n (numeric text), string (variable length).
Among numeric types, i is a 4-byte integer and int8 an 8-byte one, both suited to counts, seat numbers or loop counters. p LENGTH x DECIMALS y is a packed number, giving exact decimal arithmetic — this is what amounts and quantities should use, and indeed the dictionary's CURR and QUAN field types are themselves packed. decfloat16 and decfloat34 are decimal floating-point types, giving exact decimal rounding across a large range. f is binary floating point, and carries rounding errors that make it unsuitable for money. Numbers: i/int8 (integers), p (packed decimals for amounts), decfloat16/34, f (avoid for money).
Create a free account to keep reading
You have read the opening of this lesson. A free ERPClimb account unlocks the rest of it, every other lesson and topic, and your learning history, so you can pick up exactly where you stopped. No card needed.
- Full explanation
- Code example
- Real project scenario
- Common mistakes
- Best practices
- Interview angle
One tap with Google works too. Every topic keeps its first lesson open to everyone.
Keep exploring
Check before use: lesson examples are educational, not a guarantee of correctness for your SAP edition or release. Sample code has not been executed on your SAP system. Confirm API availability, syntax, authorizations and business impact in an approved development or test environment.