IT CanvassTalk to an advisor
SAP ABAP development · LessonBy , SAP Trainer, 10 yrs · Published · SAP S/4HANA 2023 · all levels

Data types

Data types define the kind and size of data an ABAP variable holds. ABAP has a rich type system, built-in elementary types, dictionary types, and complex types, and using the right types is fundamental to correct, maintainable programs.

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.

Practice challenge

+0 XPStreak ×0
Question 1 of 3
Which statement is true of Data types?

Frequently asked questions

What does the term Data types refer to in SAP?
Data types define the kind and size of data an ABAP variable holds. ABAP has a rich type system, built-in elementary types, dictionary types, and complex types, and using the right types is fundamental to correct, maintainable programs.
What is another point to note about Data types?
Correct types prevent truncation, rounding and conversion errors, especially for amounts (use packed p or currency/quantity dictionary types, never float for money).
What else is worth knowing about Data 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.
What tends to go wrong with Data types?
Using float (f) for money, use packed/currency types. Hard-coding lengths instead of dictionary types. Character/numeric confusion causing conversion errors.
Already working on SAP and stuck on a live ticket?Get an expert SAP developer on screen-share to finish your daily tasks with you. Deliver on time, protect your reputation and your job. Monthly support only, no task-wise plans.Task assigned · no idea where to startStill stuck · your job on the lineExpert joins your screenDelivered on timeExplore On Job Support