Data types
Quick answer
Correct types prevent truncation, rounding and conversion errors, especially for amounts (use packed p or currency/quantity dictionary types, never float for money).
Key takeaways
- Rather than hard-coding lengths, ABAP encourages typing from the ABAP Dictionary, data elements and domains that define a field’s…
- Character: c (fixed char), string (variable), n (numeric text).
- Numeric: i (integer), p (packed decimal, for amounts), f (float), and modern int8/decfloat.
- Watch out: Using float (f) for money, use packed/currency types.
Elementary built-in types
- Character: c (fixed char), string (variable), n (numeric text).
- Numeric: i (integer), p (packed decimal, for amounts), f (float), and modern int8/decfloat.
- Date/time: d (date, YYYYMMDD), t (time).
- Byte: x (hex), xstring.
Dictionary types
Rather than hard-coding lengths, ABAP encourages typing from the ABAP Dictionary, data elements and domains that define a field’s type, length and semantics centrally. Typing a variable as, say, MATNR (material number) gives it the correct, consistent definition used across SAP.
Declaring variables
DATA: lv_count TYPE i,
lv_amount TYPE p LENGTH 9 DECIMALS 2,
lv_matnr TYPE matnr, " dictionary type
lv_text TYPE string.Why types matter
Correct types prevent truncation, rounding and conversion errors, especially for amounts (use packed p or currency/quantity dictionary types, never float for money). Dictionary typing also keeps custom code consistent with SAP’s data model.
Common pitfalls
- Using float (f) for money, use packed/currency types.
- Hard-coding lengths instead of dictionary types.
- Character/numeric confusion causing conversion errors.
Want to learn this properly?
Our live, instructor-led SAP Training covers this hands-on, with real projects and a certification path.
Check your understanding
Which statement is true of Data types?
- A. Typing a variable as, say, MATNR (material number) gives it the correct, consistent definition used across…
- B. ME22N is the SAP transaction code for Change Purchase Order (MM).
- C. SAP skills power some of the most stable, well-paid careers in enterprise IT, because SAP runs the core of…
Show answer
A. Typing a variable as, say, MATNR (material number) gives it the correct, consistent definition used across…
Covered in the “Dictionary types” section of this lesson.
Which of these also applies to Data types?
- A. Collapsing the tiers mentally, they are distinct for good reasons.
- B. Learning features, not the end-to-end process.
- C. Dictionary typing also keeps custom code consistent with SAP’s data model.
Show answer
C. Dictionary typing also keeps custom code consistent with SAP’s data model.
Covered in the “Why types matter” section of this lesson.
Which part of the Learn SAP curriculum covers Data types?
- A. SAP administration
- B. SAP projects
- C. SAP ABAP development
Show answer
C. SAP ABAP development
This lesson sits in the SAP ABAP development section of the Learn SAP course.