sap-abap-cds
This skill provides comprehensive reference material for SAP ABAP CDS development, covering view creation, data modeling with annotations, associations, access control with DCL, built-in functions, and error troubleshooting. Use it when designing CDS views or view entities, implementing semantic enrichment, building Fiori Elements applications that consume CDS objects, or working with CDS features across ABAP versions 7.40 SP8 through ABAP Cloud.
git clone --depth 1 https://github.com/secondsky/sap-skills /tmp/sap-abap-cds && cp -r /tmp/sap-abap-cds/plugins/sap-abap-cds/skills/sap-abap-cds ~/.claude/skills/sap-abap-cdsSKILL.md
# SAP ABAP CDS (Core Data Services)
## Related Skills
- **sap-abap**: Use for ABAP programming patterns used with CDS or when implementing EML statements in ABAP
- **sap-btp-cloud-platform**: Use for CDS deployment scenarios on BTP or ABAP Environment configurations
- **sap-fiori-tools**: Use when building Fiori Elements applications that consume CDS views or working with UI annotations
- **sap-cap-capire**: Use for comparing CDS syntax between ABAP and CAP or when integrating ABAP CDS with CAP services
- **sap-api-style**: Use when documenting CDS-based OData services or following API documentation standards
**Quick Reference**: [https://help.sap.com/doc/abapdocu_cp_index_htm/CLOUD/en-US/abencds.html](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](https://github.com/SAP-samples/abap-cheat-sheets/blob/main/15_CDS_View_Entities.md)
## Version Compatibility
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.
## Table of Contents
- [1. CDS View Fundamentals](#1-cds-view-fundamentals)
- [2. Essential Annotations](#2-essential-annotations)
- [3. Expressions and Operations](#3-expressions-and-operations)
- [4. Built-in Functions](#4-built-in-functions)
- [5. Joins](#5-joins)
- [6. Associations](#6-associations)
- [7. Input Parameters](#7-input-parameters)
- [8. Aggregate Expressions](#8-aggregate-expressions)
- [9. Access Control (DCL)](#9-access-control-dcl)
- [10. Data Retrieval from ABAP](#10-data-retrieval-from-abap)
- [11. Common Errors and Solutions](#11-common-errors-and-solutions)
- [12. Useful Transactions and Tables](#12-useful-transactions-and-tables)
- [Bundled Resources](#bundled-resources)
- [Source Documentation](#source-documentation)
---
## 1. CDS View Fundamentals
### View Types
| 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.
### Basic CDS View Syntax
```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
}
```
### CDS View Entity Syntax (7.55+)
```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.
### Eclipse ADT Setup
1. **File** → **New** → **Other** → **Core Data Services** → **Data Definition**
2. Enter name, description, and package
3. Select template (view, view entity, etc.)
---
## 2. Essential Annotations
### Core Annotations
**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 extensions
**Complete Reference**: See `references/annotations-reference.md` for 50+ annotations with examples.
### Semantics Annotations (Currency/Quantity)
**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
```
### UI Annotations (Fiori Elements)
```sql
@UI.lineItem: [{ position: 10 }]
@UI.identification: [{ position: 10 }]
@UI.selectionField: [{ position: 10 }]
field1,
@UI.hidden: true
internal_field
```
### Consumption Annotations (Value Help)
```sql
@Consumption.valueHelpDefinition: [{
entity: { name: 'I_Currency', element: 'Currency' }
}]
waers
```
For complete annotation reference, see `references/annotations-reference.md`.
---
## 3. Expressions and Operations
### CASE Expressions
**Simple CASE** (single variable comparison):
```sql
case status
when 'A' then 'Active'
when 'I' then 'Inactive'
else 'Unknown'
end as StatusText
```
**Searched CASE** (multiple conditions):
```sql
case
when amount > 1000 then 'High'
when amount > 100 then 'Medium'
else 'Low'
end as AmountCategory
```
### Comparison Operators
**StandAnalyze a codebase and recommend Claude Code automations (hooks, subagents, skills, plugins, MCP servers). Use when user asks for automation recommendations, wants to optimize their Claude Code setup, mentions improving Claude Code workflows, asks how to first set up Claude Code for a project, or wants to know what Claude Code features they should use.
Audit and improve CLAUDE.md files in repositories. Use when user asks to check, audit, update, improve, or fix CLAUDE.md files. Scans for all CLAUDE.md files, evaluates quality against templates, outputs quality report, then makes targeted updates. Also use when the user mentions "CLAUDE.md maintenance" or "project memory optimization".
Secure dependency upgrades with supply chain protection, cooldowns, and staged rollout. Use when upgrading deps, configuring security policies, or preventing supply chain attacks.
Interview the user relentlessly about a plan or design until reaching shared understanding, resolving each branch of the decision tree. Use when user wants to stress-test a plan, get grilled on their design, or mentions "grill me".
|
|
|
|