ERPClimb logoERPClimb
ABAP Core
ABAP Developmentbeginner 8 min read

ABAP Core Part 3: Data Types and Literals

Preview · a free account unlocks the full lesson

Key takeaway

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 sections

Visual overview

ABAP Core Part 3: Data Types and Literals — learning sheetIn one line: 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.ERPClimb.com / ABAP / LESSON 3/10 / LEARNING SHEETABAP Core Part 3: Data Types and Literals1 · IN ONE LINEKnow ABAP's built-in types — character, numeric, date/time, string and packed — how literalswork, where lengths and decimals matter, and which type to choose for business data.2 · KEY IDEAS EXPLAINEDCharacter-Like Typesc LENGTH n — fixed length, padded with blanks.Most dictionary fields (airline, names) are c.n LENGTH n — digits only, leading zeros (e.g.document numbers like '0000004711'). Not forcalculations.Numeric Typesi (4-byte integer), int8 (8-byte) — counts, seats,loop counters.p LENGTH x DECIMALS y — packed number: exactdecimal arithmetic. Use for amounts and quantities(dictionary CURR/QUAN fields are packed).Date And Timed — 'YYYYMMDD'; lv_date + 30 gives the date 30days later; difference of two dates = days.t — 'HHMMSS'; arithmetic in seconds.Byte Typesx and xstring — binary data (files, hashes,attachments).3 · DO · AVOIDBest practice!Common mistakeUse dictionary types for business data.Packed (p) or decfloat for amounts; never f.string for dynamic texts; templates forbuilding them.✕Using type f for money.✕Calculating with n fields.✕Expecting text literals to keep trailingspaces.4 · IN A REAL PROJECTA custom commission calculation used type f for amounts because "it has more precision". Month-endtotals differed from FI postings by a few cents on thousands of documents, and auditors asked for anexplanation. The team switched all amount variables to dictionary-based packed types, rounded explicitly where…Original ERPClimb learning sheet • Verify against your SAP release and edition

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).

Free account

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.