Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Comprehensive SAP ABAP CDS (Core Data Services) reference for data modeling, view development, and semantic enrichment. Use when creating CDS views or view entities, defining data models with annotations, working with associations and cardinality, implementing input parameters, using built-in functions, writing CASE expressions, implementing access control with DCL, handling CURR/QUAN data types, troubleshooting CDS errors, querying CDS views from ABAP, or displaying data with SALV IDA. Covers A
.claude/skills/secondsky-sap-abap-cds/SKILL.md| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-04 | ✗→✓ | ▲ Improved | 300% | 0% |
| case-07 | ✗→✓ | ▲ Improved | 216% | 0% |
| case-08 | ✗→✓ | ▲ Improved | 270% | 0% |
| case-10 | ✗→✓ | ▲ Improved | 425% | 0% |
| case-12 | ✗→✓ | ▲ Improved | 494% | 0% |
Use this skill when creating ABAP CDS views or view entities, defining associations and cardinalities, adding UI or semantic annotations, implementing DCL access control, handling currency/unit fields, troubleshooting CDS compiler errors, or comparing classic CDS views with newer view entities.
Quick Reference: https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/abencds.html | SAP Cheat Sheets: https://github.com/SAP-samples/abap-cheat-sheets/blob/main/15_CDS_View_Entities.md
This skill covers CDS features from 7.40 SP8 through ABAP Cloud. Key version boundaries:
| Feature | 7.40 SP8 | 7.50 | 7.51 | 7.55+ | |---------|:--------:|:----:|:----:|:-----:| | CDS View (DEFINE VIEW) | x | x | x | x | | CDS associations, parameters, built-in functions | x | x | x | x | | CDS Table Functions (DEFINE TABLE FUNCTION) | | x | x | x | | CDS Access Control (DEFINE ROLE / pfcg_auth) | x | x | x | x | | CDS Access Control (implicit evaluation) | | x | x | x | | Session variables ($session.user/client/system_language) | x | x | x | x | | @Environment.systemField annotation | | x | x | x | | UPPER/LOWER functions | | | x | x | | $session.system_date | | | x | x | | CDS Metadata Extensions (ANNOTATE VIEW) | | | x | x | | Cross Join in CDS | | | x | x | | CDS View Entity (DEFINE VIEW ENTITY) | | | | x | | New cardinality syntax (to one/to many) | | | | 7.57+ |
On a 7.40 system: Use DEFINE VIEW (not DEFINE VIEW ENTITY). CDS table functions are not available before 7.50. Basic DCL (DEFINE ROLE with pfcg_auth) is available from 7.40 SP08, but implicit role evaluation in ABAP SQL requires 7.50+. $session.user/client/system_language are available from 7.40 SP08. The templates in templates/ include both classic CDS View and View Entity variants.
| Type | Syntax | Database View | Since | |------|--------|---------------|-------| | CDS View | DEFINE VIEW | Yes | 7.4 SP8 | | CDS View Entity | DEFINE VIEW ENTITY | No | 7.55 |
Recommendation: Use CDS View Entities for new development.
sql@AbapCatalog.sqlViewName: 'ZCDS_EXAMPLE_V' @AbapCatalog.compiler.CompareFilter: true @AccessControl.authorizationCheck: #NOT_REQUIRED @EndUserText.label: 'Example CDS View' define view ZCDS_EXAMPLE as select from db_table as t { key t.field1, t.field2, t.field3 as AliasName }
sql@AccessControl.authorizationCheck: #NOT_REQUIRED @EndUserText.label: 'Example View Entity' define view entity Z_CDS_EXAMPLE as select from db_table as t { key t.field1, t.field2, t.field3 as AliasName }
Key Difference: View entities omit @AbapCatalog.sqlViewName - no SQL view generated.
Essential annotations for CDS development:
@AbapCatalog.sqlViewName - SQL view name (max 16 chars)@AbapCatalog.compiler.CompareFilter - Optimize WHERE clauses@AccessControl.authorizationCheck - Set to #NOT_REQUIRED, #CHECK, #MANDATORY, or #NOT_ALLOWED@EndUserText.label - User-facing description@Metadata.allowExtensions - Allow view extensionsComplete Reference: See references/annotations-reference.md for 50+ annotations with examples.
Required for CURR and QUAN data types to avoid error SD_CDS_ENTITY105:
sql-- Currency fields @Semantics.currencyCode: true waers, @Semantics.amount.currencyCode: 'waers' amount, -- Quantity fields @Semantics.unitOfMeasure: true meins, @Semantics.quantity.unitOfMeasure: 'meins' quantity
sql@UI.lineItem: [{ position: 10 }] @UI.identification: [{ position: 10 }] @UI.selectionField: [{ position: 10 }] field1, @UI.hidden: true internal_field
sql@Consumption.valueHelpDefinition: [{ entity: { name: 'I_Currency', element: 'Currency' } }] waers
For complete annotation reference, see references/annotations-reference.md.
Simple CASE (single variable comparison):
sqlcase status when 'A' then 'Active' when 'I' then 'Inactive' else 'Unknown' end as StatusText
Searched CASE (multiple conditions):
sqlcase when amount > 1000 then 'High' when amount > 100 then 'Medium' else 'Low' end as AmountCategory
Standard operators: =, <>, <, >, <=, >= Special operators: BETWEEN x AND y, LIKE, IS NULL, IS NOT NULL
Complete Reference: See references/expressions-reference.md for all operators and expressions.
sqlquantity * price as TotalAmount, amount / 100 as Percentage, -amount as NegatedAmount
Available system variables (SY fields equivalent):
$session.user (SY-UNAME) - Current user 7.40 SP08+]$session.client (SY-MANDT) - Client 7.40 SP08+]$session.system_language (SY-LANGU) - Language 7.40 SP08+]$session.system_date (SY-DATUM) - Current date 7.51+]> Note: $session.user/client/system_language are available from 7.40 SP08. > $session.system_date requires 7.51+. @Environment.systemField requires 7.50+.
Complete Reference: See references/expressions-reference.md for all system variables.
sql$session.user as CurrentUser, $session.system_date as Today
CDS provides comprehensive built-in functions for string, numeric, and date operations.
> Note: upper() and lower() in CDS require 7.51+. On 7.40/7.50, case > conversion must be performed in ABAP after selecting (there is no CDS equivalent).
Complete Reference: See references/functions-reference.md for all 50+ functions with examples.
sql-- String operations concat(first_name, last_name) as FullName, upper(name) as UpperName, substring(description, 1, 10) as ShortDesc -- Numeric operations abs(amount) as AbsoluteAmount, round(value, 2) as RoundedValue, division(10, 3, 2) as PreciseDivision -- Date operations dats_add_days(current_date, 7) as NextWeek, dats_days_between(start_date, end_date) as Duration -- Type conversion cast(field as abap.char(10)) as TextField, cast(amount as abap.curr(15,2)) as CurrencyField **ABAP Types**: `abap.char()`, `abap.numc()`, `abap.int4`, `abap.dats`, `abap.tims`, `abap.curr()`, `abap.cuky`, `abap.quan()`, `abap.unit()` --- ## 5. Joins ### Join Types
-- INNER JOIN (matching rows only) inner join makt as t on m.matnr = t.matnr
-- LEFT OUTER JOIN (all from left, matching from right) left outer join marc as c on m.matnr = c.matnr
-- RIGHT OUTER JOIN (all from right, matching from left) -- 7.51+] right outer join mvke as v on m.matnr = v.matnr
-- CROSS JOIN (cartesian product) -- 7.51+] cross join t001 as co
---
## 6. Associations
Associations define relationships between entities (join-on-demand):
### Defining Associations
define view Z_ASSOC_EXAMPLE as select from scarr as c association 1..] to spfli as _Flights on $projection.carrid = _Flights.carrid association 0..1] to sairport as _Airport on $projection.hub = _Airport.id { key c.carrid, c.carrname, c.hub,
// Expose associations _Flights, _Airport }
### Cardinality Notation
**Syntax mapping**:
- `[0..1]` or `[1]` → `association to one` (LEFT OUTER MANY TO ONE)
- `[1..1]` → `association to one` (exact match)
- `[0..*]` or `[*]` → `association to many` (LEFT OUTER MANY TO MANY)
- `[1..*]` → `association to many` (one or more)
**Complete Reference**: See `references/associations-reference.md` for detailed cardinality guide.
### New Cardinality Syntax (Release 2302+)
association to one _Customer on ... -- 0..1] association to many _Items on ... -- 0..]
### Using Associations
-- Expose for consumer use _Customer,
-- Ad-hoc field access (triggers join) _Customer.name as CustomerName
### Path Expressions with Filter
-- Filter with cardinality indicator _Items1: Status = 'A'].ItemNo
For complete association reference, see `references/associations-reference.md`.
---
## 7. Input Parameters
### Defining Parameters
define view Z_PARAM_EXAMPLE with parameters p_date_from : dats, p_date_to : dats, @Environment.systemField: #SYSTEM_LANGUAGE p_langu : spras as select from vbak as v { key v.vbeln, v.erdat, v.erzet } where v.erdat between :p_date_from and :p_date_to
### Parameter Reference
Use colon notation `:p_date_from` or `$parameters.p_date_from`
**Calling from ABAP**:SELECT FROM z_param_example( p_date_from = '20240101', p_date_to = '20241231', p_langu = @sy-langu ) INTO TABLE @DATA(lt_result).
---
## 8. Aggregate Expressions
### Aggregate Functions
define view Z_AGG_EXAMPLE as select from vbap as i { i.vbeln, sum(i.netwr) as TotalAmount, avg(i.netwr) as AvgAmount, max(i.netwr) as MaxAmount, min(i.netwr) as MinAmount, count() as ItemCount } group by i.vbeln having sum(i.netwr) > 1000
---
## 9. Access Control (DCL)
### Basic DCL Structure
@MappingRole: true define role Z_CDS_EXAMPLE_DCL { grant select on Z_CDS_EXAMPLE where (bukrs) = aspect pfcg_auth(F_BKPF_BUK, BUKRS, ACTVT = '03'); }
### Authorization Check Options
**Available values**:
- `#NOT_REQUIRED` - No authorization check
- `#CHECK` - Warning if no DCL exists
- `#MANDATORY` - Error if no DCL exists
- `#NOT_ALLOWED` - DCL ignored if exists
**Complete Reference**: See `references/access-control-reference.md` for detailed DCL patterns.
### Condition Types
**PFCG Authorization**: `where (field) = aspect pfcg_auth(AUTH_OBJECT, AUTH_FIELD, ACTVT = '03')`
**Literal Condition**: `where status <> 'DELETED'`
**User Aspect**: `where created_by ?= aspect user`
**Combined**: `where (bukrs) = aspect pfcg_auth(...) and status = 'ACTIVE'`
For complete access control reference, see `references/access-control-reference.md`.
---
## 10. Data Retrieval from ABAP
### Standard SELECTSELECT FROM zcds_example WHERE field1 = @lv_value INTO TABLE @DATA(lt_result).
### SALV IDA (Integrated Data Access)cl_salv_gui_table_ida=>create_for_cds_view( CONV #( 'ZCDS_EXAMPLE' ) )->fullscreen( )->display( ).
---
## 11. Common Errors and Solutions
### SD_CDS_ENTITY105: Missing Reference Information
**Problem**: CURR/QUAN fields without reference
**Solution**: Add semantics annotations@Semantics.currencyCode: true waers, @Semantics.amount.currencyCode: 'waers' netwr
Or import currency from related table:inner join t001 as c on ... { c.waers, @Semantics.amount.currencyCode: 'waers' v.amount }
### Cardinality Warnings
**Problem**: Cardinality doesn't match actual data
**Solution**: Define cardinality matching data modelassociation 0..1] to ... -- Use for optional relationships association 1..] to ... -- Use for required one-to-many
For complete troubleshooting guide, see `references/troubleshooting.md`.
---
## 12. Useful Transactions and Tables
### Key Transactions
- **SDDLAR** - Display/repair DDL structures
- **RSRTS_ODP_DIS** - TransientProvider preview
- **RSRTS_QUERY_CHECK** - CDS query metadata validation
- **SE63** - Translation (EndUserText)
- **SE11** - ABAP Dictionary
- **SU21** - Authorization objects
### Important Tables
- **DDHEADANNO** - Header-level annotations
- **CDSVIEWANNOPOS** - CDS view header annotations
- **CDS_FIELD_ANNOTATION** - Field-level annotations
- **ABDOC_CDS_ANNOS** - SAP annotation definitions
### API Class
`CL_DD_DDL_ANNOTATION_SERVICE` - Programmatic annotation access:
- `get_annos()` - Get all annotations
- `get_label_4_element()` - Get @EndUserText.label
---
## Bundled Resources
### Reference Documentation
For detailed guidance, see the reference files in `references/`:
- `annotations-reference.md` - Complete annotation catalog
- `functions-reference.md` - All built-in functions with examples
- `associations-reference.md` - Associations and cardinality guide
- `access-control-reference.md` - DCL and authorization patterns
- `expressions-reference.md` - Expressions and operators
- `troubleshooting.md` - Common errors and solutions
### Templates
For templates, see `templates/`:
- `basic-view.md` - Standard CDS view template
- `parameterized-view.md` - View with input parameters
- `dcl-template.md` - Access control definition
---
## Source Documentation
**Update this skill by checking**:
- https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/abencds.html (ABAP Cloud)
- https://help.sap.com/doc/abapdocu_740_index_htm/7.40/en-US/index.htm (7.40 Reference)
- https://help.sap.com/docs/SAP_NETWEAVER_AS_ABAP_752/f2e545608079437ab165c105649b89db/7c078765ec6d4e6b88b71bdaf8a2bd9f.html (NetWeaver 7.52 User Guide)
- https://github.com/SAP-samples/abap-cheat-sheets
- https://github.com/SAP-samples/abap-cheat-sheets/blob/main/33_ABAP_Release_News.md (Release News)
**Last Verified**: 2026-04-02| Case | Status | Duration (ms) | Turns | Tokens | Tool calls | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Without | With | Δ | Without | With | Δ | Without | With | Δ | Without | With | Δ | ||
case-04 | fail→pass | 8,164 | 6,884 | -16% | 1 | 1 | 0% | 1,528 | 6,113 | +300% | 0 | 0 | — |
case-01 | pass→pass | 9,481 | 7,603 | -20% | 1 | 1 | 0% | 1,826 | 6,327 | +246% | 0 | 0 | — |
case-02 | pass→pass | 8,345 | 5,685 | -32% | 1 | 1 | 0% | 1,367 | 5,930 | +334% | 0 | 0 | — |
case-03 | pass→pass | 7,388 | 5,475 | -26% | 1 | 1 | 0% | 1,391 | 5,871 | +322% | 0 | 0 | — |
case-05 | pass→pass | 13,279 | 11,237 | -15% | 1 | 1 | 0% | 2,302 | 6,875 | +199% | 0 | 0 | — |
case-06 | pass→pass | 9,121 | 5,524 | -39% | 1 | 1 | 0% | 1,557 | 5,956 | +283% | 0 | 0 | — |
case-07 | fail→pass | 10,614 | 7,532 | -29% | 1 | 1 | 0% | 1,977 | 6,247 | +216% | 0 | 0 | — |
case-08 | fail→pass | 7,906 | 4,330 | -45% | 1 | 1 | 0% | 1,489 | 5,510 | +270% | 0 | 0 | — |
case-22 | pass→pass | 8,749 | 7,903 | -10% | 1 | 1 | 0% | 1,611 | 6,195 | +285% | 0 | 0 | — |
case-09 | pass→pass | 9,053 | 4,285 | -53% | 1 | 1 | 0% | 1,504 | 5,551 | +269% | 0 | 0 | — |
case-10 | fail→pass | 6,966 | 6,114 | -12% | 1 | 1 | 0% | 1,135 | 5,961 | +425% | 0 | 0 | — |
case-11 | pass→pass | 8,616 | 5,197 | -40% | 1 | 1 | 0% | 1,357 | 5,804 | +328% | 0 | 0 | — |
case-12 | fail→pass | 5,489 | 7,815 | +42% | 1 | 1 | 0% | 1,078 | 6,400 | +494% | 0 | 0 | — |
case-13 | pass→pass | 8,545 | 4,863 | -43% | 1 | 1 | 0% | 1,630 | 5,647 | +246% | 0 | 0 | — |
case-14 | pass→pass | 7,781 | 8,072 | +4% | 1 | 1 | 0% | 1,367 | 6,128 | +348% | 0 | 0 | — |
case-15 | pass→pass | 6,621 | 4,652 | -30% | 1 | 1 | 0% | 1,329 | 5,705 | +329% | 0 | 0 | — |
case-16 | fail→pass | 9,387 | 6,712 | -28% | 1 | 1 | 0% | 1,725 | 6,066 | +252% | 0 | 0 | — |
case-17 | pass→pass | 5,682 | 4,084 | -28% | 1 | 1 | 0% | 1,090 | 5,517 | +406% | 0 | 0 | — |
case-18 | fail→pass | 7,347 | 4,535 | -38% | 1 | 1 | 0% | 1,384 | 5,529 | +299% | 0 | 0 | — |
case-19 | fail→pass | 6,938 | 4,367 | -37% | 1 | 1 | 0% | 1,263 | 5,577 | +342% | 0 | 0 | — |
case-20 | pass→pass | 9,590 | 6,518 | -32% | 1 | 1 | 0% | 1,628 | 5,861 | +260% | 0 | 0 | — |
case-21 | pass→fail | 5,918 | 6,202 | +5% | 1 | 1 | 0% | 1,001 | 5,958 | +495% | 0 | 0 | — |
DecimalAI ran this skill against gemini-3.6-flash twice over the same eval suite — once with the skill loaded and once without — and compared the two runs case by case. 22 cases were attempted. The headline lift of +32 percentage points is the difference between those two pass rates over the 22 comparable cases. 1 case got worse with the skill loaded, and it is included in that figure.
Without the skill loaded, the model failed this case. With it loaded, the same prompt on the same model passed. This is one improved case from the latest verified run; every case, including any that regressed, is in the table above.
Other measured skills in the registry, with their headline benchmark lift.