IT CanvassTalk to an advisor
SAP ABAP development · LessonReviewed by Ravi M, SAP Trainer, 10 yrs · Updated · Published · SAP S/4HANA 2023 · all levels

SAP 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

ABAP has elementary built-in types, c, string, n, i, p, f, d, t and x among them, and Dictionary types such as MATNR that carry a field's length and meaning from the ABAP Dictionary. Declare with DATA and TYPE. Amounts use packed p or currency types, never float, because float rounds money. Dictionary typing keeps custom code consistent with SAP.

Key takeaways
  • 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.
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