Understanding ABAP CDS Built-in Data Types

40 min read

Why Every ABAP Cloud Developer Must Understand CDS Data Types

One of the first things developers notice when moving from classical ABAP programming to ABAP CDS View Entities is that data types are defined differently.

Although ABAP Classes and CDS View Entities share many common data types, their syntax is different. Understanding these differences is essential because almost every CDS expression—including CAST, CASE, arithmetic operations, currency handling, quantity calculations, and conversion functions—depends on choosing the correct data type.

If you are building RAP applications, CDS View Entities, or APIs in SAP S/4HANA Public Cloud, this is one lesson you should master before moving on to more advanced topics.

ABAP CDS Built-in Data Types
Built-in data types form the foundation for every CDS View Entity, RAP Business Object, and Code Pushdown expression.
Click image to enlarge

CDS View Entities and ABAP Classes Do Not Use the Same Syntax

One of the most common mistakes beginners make is assuming that CDS uses exactly the same syntax as ABAP Classes.

Although the underlying concepts are similar, CDS View Entities define data types using the abap.* namespace, whereas ABAP Classes use the traditional ABAP type system.

CDS vs ABAP Class Syntax

ConceptCDS View EntityABAP Class
Characterabap.char(40)TYPE c LENGTH 40
Integerabap.int4TYPE int4
Decimalabap.dec(15,2)TYPE p LENGTH 8 DECIMALS 2
Dateabap.datsTYPE d
Timeabap.timsTYPE t
Stringabap.stringTYPE string

Architect Perspective

Architect Insight

Every experienced RAP developer is comfortable working in both worlds.

CDS View Entities use the abap.* syntax for defining data types, while ABAP Classes continue to use the traditional ABAP type declarations.

Throughout a RAP application, you will switch between these two syntaxes many times every day.

Categories of Built-in Data Types

Instead of memorizing every individual data type, it is much easier to group them into logical categories.

ABAP CDS Built-in Data Type Categories

CategoryExamplesTypical Usage
CharacterCHAR, NUMC, STRING, SSTRINGBusiness identifiers and text
NumericINT1, INT2, INT4, INT8, DECCounters, quantities, calculations
Decimal FloatingDECFLOAT16, DECFLOAT34Financial calculations
Currency & QuantityCURR, QUAN, CUKY, UNITAmounts and units
Date & TimeDATS, TIMSBusiness dates and times
BinaryRAW, RAWSTRINGUUIDs and binary content

We will study each category individually before learning how they are used in CAST expressions and advanced CDS functions.

When Do You Choose a Built-in Data Type?

Built-in data types should be selected based on the nature of the data you are modeling rather than simply choosing the largest available type.

Real Project Example: Choosing the Right Type

A Company Code should not be modeled using abap.string.

Likewise, a Product Description should not be modeled using abap.char(4).

Choosing the correct data type improves readability, storage efficiency, validation, and long-term maintainability.

💡 SAP Best Practice

Select the smallest data type that accurately represents the business requirement. Avoid using generic string types unless the length of the value is truly unpredictable.

Character Data Types

Character data types are the most frequently used built-in types in CDS View Entities. They are used to store identifiers, codes, descriptions, language keys, and other textual business information.

Although they appear simple, each character type serves a different purpose. Choosing the correct type improves readability and prevents unnecessary conversions later in RAP development.

1. CHAR (Fixed-Length Character)

abap.char() is the most commonly used built-in data type in CDS. It stores a fixed number of characters and is typically used for business identifiers whose length never changes.

CHAR Syntax Comparison

CDS View EntityABAP ClassTypical Usage
abap.char(40)TYPE c LENGTH 40Material Description
abap.char(4)TYPE c LENGTH 4Company Code
abap.char(2)TYPE c LENGTH 2Language
CDS View Entity
ABAP CDS
cast( Supplier as abap.char(10) ) as SupplierText,
cast( Material as abap.char(40) ) as MaterialDescription
ABAP Class
ABAP
DATA lv_company TYPE c LENGTH 4.
DATA lv_name    TYPE c LENGTH 40.

Common SAP Examples

Business FieldLength
Company CodeCHAR(4)
PlantCHAR(4)
Storage LocationCHAR(4)
LanguageCHAR(2)
User IDCHAR(12)

💡 SAP Best Practice

Use abap.char() when the maximum length of the value is known and remains fixed.

2. NUMC (Numeric Character)

Although NUMC contains only digits, it is still treated as a character-based data type rather than a numeric type.

NUMC is commonly used for business document numbers where leading zeros must be preserved.

NUMC Syntax Comparison

CDS View EntityABAP ClassTypical Usage
abap.numc(10)TYPE n LENGTH 10Purchase Order
CDS View Entity
ABAP CDS
cast( PurchaseOrder as abap.numc(10) ) as PurchaseOrder
ABAP Class
ABAP
DATA lv_po TYPE n LENGTH 10.

Example value:

NUMC Value
ABAP CDS
4500001234

Architect Perspective

Architect Insight

NUMC is often misunderstood.

Although it contains only digits, SAP treats NUMC as a character field. It should not be used for arithmetic calculations.

If mathematical operations are required, use one of the numeric data types such as abap.int4 orabap.dec().

3. STRING

abap.string stores variable-length text without requiring a predefined maximum length.

STRING Syntax Comparison

CDS View EntityABAP ClassTypical Usage
abap.stringTYPE stringLong Descriptions
CDS View Entity
ABAP CDS
cast( ProductDescription as abap.string ) as Description
ABAP Class
ABAP
DATA lv_text TYPE string.

💡 SAP Best Practice

Avoid using abap.string unless the length of the value is genuinely unknown or highly variable.

4. SSTRING

abap.sstring() represents a short variable-length string and is commonly used in CDS View Entities.

Unlike abap.string, the maximum length must be specified.

SSTRING Syntax Comparison

CDS View EntityABAP ClassTypical Usage
abap.sstring(255)TYPE stringShort Descriptions
CDS View Entity
ABAP CDS
cast( ProductText as abap.sstring(255) ) as ProductText
ABAP Class
ABAP
DATA lv_text TYPE string.

Although ABAP does not provide an SSTRING keyword for variable declarations, the type is widely used in the Dictionary and CDS View Entities.

🔤
Developer Reference

Character Data Types Cheat Sheet

4 Character Types • Text Handling • Business Identifiers

This quick reference summarizes the character data types available in ABAP CDS. Use it while selecting appropriate data types for business keys, descriptions, text fields, and variable-length content.

TypeCDS SyntaxABAP TypeTypical Usage
CHARabap.char(40)TYPE c LENGTH 40Fixed-length text, IDs, Codes
NUMCabap.numc(10)TYPE n LENGTH 10Business document numbers, Customer IDs
STRINGabap.stringTYPE stringLong descriptions, Comments
SSTRINGabap.sstring(255)TYPE stringShort variable-length text

Numeric Data Types

Numeric data types are used whenever mathematical calculations, aggregations, comparisons, or arithmetic expressions are required.

Unlike character types, numeric data types can participate in calculations without requiring explicit conversions.

SAP provides several numeric data types, each designed for different precision and storage requirements.

1. Integer Types (INT1, INT2, INT4, INT8)

Integer data types store whole numbers without decimal places. They are commonly used for counters, quantities, loop indexes, flags, and other numeric values that never require fractions.

Integer Types

CDS TypeABAP ClassTypical Usage
abap.int1TYPE int1Small Counters
abap.int2TYPE int2Small Numeric Values
abap.int4TYPE int4Standard Integer
abap.int8TYPE int8Very Large Numbers
CDS View Entity
ABAP CDS
cast( ItemCount as abap.int4 ) as ItemCount,
cast( SequenceNo as abap.int8 ) as SequenceNumber
ABAP Class
ABAP
DATA lv_counter TYPE int4.
DATA lv_sequence TYPE int8.

💡 SAP Best Practice

Use abap.int4 as the default integer type unless there is a specific reason to use a smaller or larger integer.

2. DEC (Packed Decimal)

abap.dec() represents fixed-point decimal numbers and is one of the most commonly used numeric data types in CDS View Entities.

It is ideal for storing monetary values, percentages, tax amounts, discounts, and business calculations requiring a fixed number of decimal places.

DEC Syntax Comparison

CDS View EntityABAP ClassExample
abap.dec(15,2)TYPE p LENGTH 8 DECIMALS 21250.50
CDS View Entity
ABAP CDS
cast( NetAmount as abap.dec(15,2) ) as NetAmount
ABAP Class
ABAP
DATA lv_tax TYPE p LENGTH 8 DECIMALS 2.

Architect Perspective

Architect Insight

This is one of the most common areas of confusion.

In CDS, abap.dec(15,2) specifies the total number of digits and decimal places.

In ABAP Classes, packed numbers are declared using LENGTH in bytes together with the number of decimal places.

Although both represent packed decimals, the declaration syntax is completely different.

3. DECFLOAT16

abap.decfloat16 stores decimal floating-point numbers with approximately 16 digits of precision.

It provides higher precision than packed decimals and is frequently used for exchange rates and financial calculations.

DECFLOAT16 Syntax Comparison

CDS View EntityABAP ClassTypical Usage
abap.decfloat16TYPE decfloat16Exchange Rate
CDS View Entity
ABAP CDS
cast( ExchangeRate as abap.decfloat16 ) as ExchangeRate
ABAP Class
ABAP
DATA lv_rate TYPE decfloat16.

4. DECFLOAT34

abap.decfloat34 offers approximately 34 digits of precision and is the preferred choice for high-precision business calculations.

DECFLOAT34 Syntax Comparison

CDS View EntityABAP ClassTypical Usage
abap.decfloat34TYPE decfloat34Financial Calculations
CDS View Entity
ABAP CDS
cast( Amount as abap.decfloat34 ) as Amount
ABAP Class
ABAP
DATA lv_amount TYPE decfloat34.

💡 SAP Best Practice

Whenever calculations require very high precision, SAP generally recommends using DECFLOAT types instead of traditional floating-point numbers.

5. FLTP (Floating Point)

abap.fltp represents binary floating-point numbers.

Although it supports decimal values, floating-point arithmetic may introduce rounding differences due to binary representation.

FLTP Syntax Comparison

CDS View EntityABAP ClassTypical Usage
abap.fltpTYPE fScientific Calculations
CDS View Entity
ABAP CDS
cast( Ratio as abap.fltp ) as Ratio
ABAP Class
ABAP
DATA lv_ratio TYPE f.

Common Mistakes

  • Using FLTP for currency calculations.
  • Confusing DEC with DECFLOAT.
  • Assuming INT types support decimal values.
  • Using DECFLOAT when fixed decimal precision is required.
🧮
Developer Reference

Numeric Data Types Cheat Sheet

8 Numeric Types • Calculations • Financial & Analytical Processing

This quick reference summarizes the numeric data types available in ABAP CDS. Use it while designing CDS View Entities for calculations, quantities, financial values, and analytical reporting.

TypeCDS SyntaxABAP TypeCommon Use Cases
INT1abap.int1TYPE int1Flags, Counters, Small Numeric Values
INT2abap.int2TYPE int2Small Quantities, Counters
INT4abap.int4TYPE int4Document Counts, IDs, Standard Calculations
INT8abap.int8TYPE int8Large Counters, High-Volume Analytics
DECabap.dec(15,2)TYPE pFinancial Values, Percentages, Fixed Decimal Calculations
DECFLOAT16abap.decfloat16TYPE decfloat16Scientific & High-Precision Calculations
DECFLOAT34abap.decfloat34TYPE decfloat34Very High Precision Financial & Scientific Calculations
FLTPabap.fltpTYPE fApproximate Floating-Point Calculations

Currency, Quantity, Date and Binary Data Types

Besides character and numeric types, CDS View Entities provide specialized built-in data types for handling currencies, quantities, dates, times, clients, and binary data. These types are widely used in RAP applications and SAP standard VDM views.

1. CURR (Currency Amount)

abap.curr() represents a currency amount. It should be used together with a corresponding currency key field for proper currency semantics.

CURR Syntax Comparison

CDS View EntityABAP ClassExample
abap.curr(15,2)TYPE wrbtr (or TYPE p ...)125000.50 INR
CDS View Entity
ABAP CDS
cast( NetAmount as abap.curr(15,2) ) as NetAmount
ABAP Class
ABAP
DATA lv_amount TYPE wrbtr.

2. QUAN (Quantity)

abap.quan() represents a business quantity. Like CURR, it should always be associated with a Unit of Measure field.

QUAN Syntax Comparison

CDS View EntityABAP ClassExample
abap.quan(13,3)TYPE menge_d250.500 KG
CDS View Entity
ABAP CDS
cast( Quantity as abap.quan(13,3) ) as Quantity
ABAP Class
ABAP
DATA lv_qty TYPE menge_d.

3. DATS and TIMS

Dates and times are represented using dedicated built-in data types. These are frequently used in business documents, audit fields, and RAP applications.

Date & Time Types

TypeCDS SyntaxABAP ClassExample
Dateabap.datsTYPE d20260702
Timeabap.timsTYPE t143015
CDS View Entity
ABAP CDS
cast( CreationDate as abap.dats ) as CreationDate,
cast( CreationTime as abap.tims ) as CreationTime

4. CUKY, UNIT and CLNT

SAP provides dedicated built-in types for currencies, units of measure, and client fields.

Business Semantic Built-in Types

TypePurposeTypical ABAP Type
abap.cukyCurrency KeyWAERS
abap.unitUnit of MeasureMEINS
abap.clntClientMANDT
CDS View Entity
ABAP CDS
cast( Currency as abap.cuky ) as Currency,
cast( BaseUnit as abap.unit ) as BaseUnit,
cast( Client as abap.clnt ) as Client

5. RAW and RAWSTRING

Binary data types are primarily used for UUIDs, hash values, PDF content, images, and other binary objects.

Binary Types

CDS TypeABAP ClassTypical Usage
abap.raw(16)TYPE x LENGTH 16UUID
abap.rawstringTYPE xstringPDF / Images
CDS View Entity
ABAP CDS
cast( UUID as abap.raw(16) ) as UUID
🗂️
Developer Reference

ABAP CDS Built-in Data Types Cheat Sheet

21 Built-in Types • Character • Numeric • Date/Time • Binary

This quick reference summarizes the built-in data types available in ABAP CDS View Entities. Use it while designing CDS Views, selecting appropriate data types, or preparing for technical interviews.

TypeCDS SyntaxABAP TypeExample
CHARabap.char(40)TYPE c LENGTH 40MAT001
NUMCabap.numc(10)TYPE n LENGTH 104500001234
INT1abap.int1TYPE int15
INT2abap.int2TYPE int21500
INT4abap.int4TYPE int4100000
INT8abap.int8TYPE int81234567890123
DECabap.dec(15,2)TYPE p18.50
CURRabap.curr(15,2)TYPE wrbtr1250.75
QUANabap.quan(13,3)TYPE menge_d250.500
DECFLOAT16abap.decfloat16TYPE decfloat1689.234567
DECFLOAT34abap.decfloat34TYPE decfloat3489.234567890123
FLTPabap.fltpTYPE f0.987654321
STRINGabap.stringTYPE stringLong Description
SSTRINGabap.sstring(255)TYPE stringShort Description
RAWabap.raw(16)TYPE x LENGTH 16UUID
RAWSTRINGabap.rawstringTYPE xstringPDF / Binary File
DATSabap.datsTYPE d20260702
TIMSabap.timsTYPE t143015
CUKYabap.cukyTYPE waersINR
UNITabap.unitTYPE meinsKG
CLNTabap.clntTYPE mandt100

Common Mistakes

  • Confusing CDS syntax with ABAP Class syntax.
  • Using STRING when CHAR is sufficient.
  • Using FLTP for financial calculations instead of DEC or DECFLOAT.
  • Using CURR without an associated currency key.
  • Using QUAN without an associated Unit of Measure.
  • Confusing NUMC with numeric data types.

Architect Perspective

Architect Insight

You do not need to memorize every CDS built-in data type.

Instead, understand the purpose of each category and remember the commonly used types such as CHAR, INT4, DEC, DECFLOAT34, CURR, QUAN, DATS, and TIMS.

Once these become familiar, learning CAST, CASE expressions, conversion functions, and RAP modeling becomes significantly easier because all of those features build upon these data types.

Interview Questions

BeginnerInterview Question

What is the difference between abap.char() and abap.string?

Answer: abap.char() is a fixed-length character type, whereas abap.string is variable length and intended for longer or unpredictable text.

ExperiencedInterview Question

Why is abap.dec(15,2) different from TYPE p LENGTH 8 DECIMALS 2?

Answer: In CDS, DEC specifies total digits and decimal places. In ABAP Classes, packed numbers are declared using storage length in bytes together with decimal places.

ArchitectInterview Question

Which CDS built-in data types do you use most frequently in RAP development?

Answer: The most common types are CHAR, INT4, DEC, DECFLOAT34, CURR, QUAN, DATS, TIMS, STRING, and SSTRING. The correct choice depends on the business semantics and intended calculations.

Watch the Complete ADT Walkthrough

Follow this lesson in Eclipse ADT as we demonstrate every built-in data type, compare it with the equivalent ABAP Class syntax, and explain where each type is typically used in SAP S/4HANA Public Cloud development.

💡 Key Takeaway

Built-in data types form the foundation of every CDS View Entity. Understanding when to use character, numeric, currency, quantity, date, and binary types allows you to build correct, efficient, and maintainable data models.

The next lesson introduces CAST Expressions, where you'll learn how to convert between these data types safely and how experienced SAP developers use CAST in real RAP projects.