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.

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
| Concept | CDS View Entity | ABAP Class |
|---|---|---|
| Character | abap.char(40) | TYPE c LENGTH 40 |
| Integer | abap.int4 | TYPE int4 |
| Decimal | abap.dec(15,2) | TYPE p LENGTH 8 DECIMALS 2 |
| Date | abap.dats | TYPE d |
| Time | abap.tims | TYPE t |
| String | abap.string | TYPE string |
Architect Perspective
Architect InsightEvery 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
| Category | Examples | Typical Usage |
|---|---|---|
| Character | CHAR, NUMC, STRING, SSTRING | Business identifiers and text |
| Numeric | INT1, INT2, INT4, INT8, DEC | Counters, quantities, calculations |
| Decimal Floating | DECFLOAT16, DECFLOAT34 | Financial calculations |
| Currency & Quantity | CURR, QUAN, CUKY, UNIT | Amounts and units |
| Date & Time | DATS, TIMS | Business dates and times |
| Binary | RAW, RAWSTRING | UUIDs 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 Entity | ABAP Class | Typical Usage |
|---|---|---|
| abap.char(40) | TYPE c LENGTH 40 | Material Description |
| abap.char(4) | TYPE c LENGTH 4 | Company Code |
| abap.char(2) | TYPE c LENGTH 2 | Language |
cast( Supplier as abap.char(10) ) as SupplierText,
cast( Material as abap.char(40) ) as MaterialDescriptionDATA lv_company TYPE c LENGTH 4.
DATA lv_name TYPE c LENGTH 40.Common SAP Examples
| Business Field | Length |
|---|---|
| Company Code | CHAR(4) |
| Plant | CHAR(4) |
| Storage Location | CHAR(4) |
| Language | CHAR(2) |
| User ID | CHAR(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 Entity | ABAP Class | Typical Usage |
|---|---|---|
| abap.numc(10) | TYPE n LENGTH 10 | Purchase Order |
cast( PurchaseOrder as abap.numc(10) ) as PurchaseOrderDATA lv_po TYPE n LENGTH 10.Example value:
4500001234Architect Perspective
Architect InsightNUMC 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 Entity | ABAP Class | Typical Usage |
|---|---|---|
| abap.string | TYPE string | Long Descriptions |
cast( ProductDescription as abap.string ) as DescriptionDATA 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 Entity | ABAP Class | Typical Usage |
|---|---|---|
| abap.sstring(255) | TYPE string | Short Descriptions |
cast( ProductText as abap.sstring(255) ) as ProductTextDATA 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.
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.
| Type | CDS Syntax | ABAP Type | Typical Usage |
|---|---|---|---|
| CHAR | abap.char(40) | TYPE c LENGTH 40 | Fixed-length text, IDs, Codes |
| NUMC | abap.numc(10) | TYPE n LENGTH 10 | Business document numbers, Customer IDs |
| STRING | abap.string | TYPE string | Long descriptions, Comments |
| SSTRING | abap.sstring(255) | TYPE string | Short 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 Type | ABAP Class | Typical Usage |
|---|---|---|
| abap.int1 | TYPE int1 | Small Counters |
| abap.int2 | TYPE int2 | Small Numeric Values |
| abap.int4 | TYPE int4 | Standard Integer |
| abap.int8 | TYPE int8 | Very Large Numbers |
cast( ItemCount as abap.int4 ) as ItemCount,
cast( SequenceNo as abap.int8 ) as SequenceNumberDATA 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 Entity | ABAP Class | Example |
|---|---|---|
| abap.dec(15,2) | TYPE p LENGTH 8 DECIMALS 2 | 1250.50 |
cast( NetAmount as abap.dec(15,2) ) as NetAmountDATA lv_tax TYPE p LENGTH 8 DECIMALS 2.Architect Perspective
Architect InsightThis 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 Entity | ABAP Class | Typical Usage |
|---|---|---|
| abap.decfloat16 | TYPE decfloat16 | Exchange Rate |
cast( ExchangeRate as abap.decfloat16 ) as ExchangeRateDATA 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 Entity | ABAP Class | Typical Usage |
|---|---|---|
| abap.decfloat34 | TYPE decfloat34 | Financial Calculations |
cast( Amount as abap.decfloat34 ) as AmountDATA 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 Entity | ABAP Class | Typical Usage |
|---|---|---|
| abap.fltp | TYPE f | Scientific Calculations |
cast( Ratio as abap.fltp ) as RatioDATA 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.
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.
| Type | CDS Syntax | ABAP Type | Common Use Cases |
|---|---|---|---|
| INT1 | abap.int1 | TYPE int1 | Flags, Counters, Small Numeric Values |
| INT2 | abap.int2 | TYPE int2 | Small Quantities, Counters |
| INT4 | abap.int4 | TYPE int4 | Document Counts, IDs, Standard Calculations |
| INT8 | abap.int8 | TYPE int8 | Large Counters, High-Volume Analytics |
| DEC | abap.dec(15,2) | TYPE p | Financial Values, Percentages, Fixed Decimal Calculations |
| DECFLOAT16 | abap.decfloat16 | TYPE decfloat16 | Scientific & High-Precision Calculations |
| DECFLOAT34 | abap.decfloat34 | TYPE decfloat34 | Very High Precision Financial & Scientific Calculations |
| FLTP | abap.fltp | TYPE f | Approximate 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 Entity | ABAP Class | Example |
|---|---|---|
| abap.curr(15,2) | TYPE wrbtr (or TYPE p ...) | 125000.50 INR |
cast( NetAmount as abap.curr(15,2) ) as NetAmountDATA 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 Entity | ABAP Class | Example |
|---|---|---|
| abap.quan(13,3) | TYPE menge_d | 250.500 KG |
cast( Quantity as abap.quan(13,3) ) as QuantityDATA 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
| Type | CDS Syntax | ABAP Class | Example |
|---|---|---|---|
| Date | abap.dats | TYPE d | 20260702 |
| Time | abap.tims | TYPE t | 143015 |
cast( CreationDate as abap.dats ) as CreationDate,
cast( CreationTime as abap.tims ) as CreationTime4. CUKY, UNIT and CLNT
SAP provides dedicated built-in types for currencies, units of measure, and client fields.
Business Semantic Built-in Types
| Type | Purpose | Typical ABAP Type |
|---|---|---|
| abap.cuky | Currency Key | WAERS |
| abap.unit | Unit of Measure | MEINS |
| abap.clnt | Client | MANDT |
cast( Currency as abap.cuky ) as Currency,
cast( BaseUnit as abap.unit ) as BaseUnit,
cast( Client as abap.clnt ) as Client5. RAW and RAWSTRING
Binary data types are primarily used for UUIDs, hash values, PDF content, images, and other binary objects.
Binary Types
| CDS Type | ABAP Class | Typical Usage |
|---|---|---|
| abap.raw(16) | TYPE x LENGTH 16 | UUID |
| abap.rawstring | TYPE xstring | PDF / Images |
cast( UUID as abap.raw(16) ) as UUIDABAP 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.
| Type | CDS Syntax | ABAP Type | Example |
|---|---|---|---|
| CHAR | abap.char(40) | TYPE c LENGTH 40 | MAT001 |
| NUMC | abap.numc(10) | TYPE n LENGTH 10 | 4500001234 |
| INT1 | abap.int1 | TYPE int1 | 5 |
| INT2 | abap.int2 | TYPE int2 | 1500 |
| INT4 | abap.int4 | TYPE int4 | 100000 |
| INT8 | abap.int8 | TYPE int8 | 1234567890123 |
| DEC | abap.dec(15,2) | TYPE p | 18.50 |
| CURR | abap.curr(15,2) | TYPE wrbtr | 1250.75 |
| QUAN | abap.quan(13,3) | TYPE menge_d | 250.500 |
| DECFLOAT16 | abap.decfloat16 | TYPE decfloat16 | 89.234567 |
| DECFLOAT34 | abap.decfloat34 | TYPE decfloat34 | 89.234567890123 |
| FLTP | abap.fltp | TYPE f | 0.987654321 |
| STRING | abap.string | TYPE string | Long Description |
| SSTRING | abap.sstring(255) | TYPE string | Short Description |
| RAW | abap.raw(16) | TYPE x LENGTH 16 | UUID |
| RAWSTRING | abap.rawstring | TYPE xstring | PDF / Binary File |
| DATS | abap.dats | TYPE d | 20260702 |
| TIMS | abap.tims | TYPE t | 143015 |
| CUKY | abap.cuky | TYPE waers | INR |
| UNIT | abap.unit | TYPE meins | KG |
| CLNT | abap.clnt | TYPE mandt | 100 |
❌ 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 InsightYou 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
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.
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.
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.