- **sap-abap**: Use for ABAP programming patterns used with CDS or when implementing EML statements in ABAP
/plugin marketplace add secondsky/sap-skills/plugin install sap-abap-cds@sap-skillsThis skill inherits all available tools. When active, it can use any tool Claude has access to.
README.mdreferences/access-control-reference.mdreferences/annotations-reference.mdreferences/associations-reference.mdreferences/expressions-reference.mdreferences/functions-reference.mdreferences/troubleshooting.mdtemplates/basic-view.mdtemplates/dcl-template.mdtemplates/parameterized-view.mdQuick 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
| 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.
@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
}
@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:
-- Currency fields
@Semantics.currencyCode: true
waers,
@Semantics.amount.currencyCode: 'waers'
amount,
-- Quantity fields
@Semantics.unitOfMeasure: true
meins,
@Semantics.quantity.unitOfMeasure: 'meins'
quantity
@UI.lineItem: [{ position: 10 }]
@UI.identification: [{ position: 10 }]
@UI.selectionField: [{ position: 10 }]
field1,
@UI.hidden: true
internal_field
@Consumption.valueHelpDefinition: [{
entity: { name: 'I_Currency', element: 'Currency' }
}]
waers
For complete annotation reference, see references/annotations-reference.md.
Simple CASE (single variable comparison):
case status
when 'A' then 'Active'
when 'I' then 'Inactive'
else 'Unknown'
end as StatusText
Searched CASE (multiple conditions):
case
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.
quantity * price as TotalAmount,
amount / 100 as Percentage,
-amount as NegatedAmount
Available system variables (SY fields equivalent):
$session.user (SY-UNAME) - Current user$session.client (SY-MANDT) - Client$session.system_language (SY-LANGU) - Language$session.system_date (SY-DATUM) - Current dateComplete Reference: See references/expressions-reference.md for all system variables.
$session.user as CurrentUser,
$session.system_date as Today
CDS provides comprehensive built-in functions for string, numeric, and date operations.
Complete Reference: See references/functions-reference.md for all 50+ functions with examples.
-- 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
```sql
-- 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)
right outer join mvke as v on m.matnr = v.matnr
-- CROSS JOIN (cartesian product)
cross join t001 as co
Associations define relationships between entities (join-on-demand):
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
}
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.
association to one _Customer on ... -- [0..1]
association to many _Items on ... -- [0..*]
-- Expose for consumer use
_Customer,
-- Ad-hoc field access (triggers join)
_Customer.name as CustomerName
-- Filter with cardinality indicator
_Items[1: Status = 'A'].ItemNo
For complete association reference, see references/associations-reference.md.
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
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).
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
@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');
}
Available values:
#NOT_REQUIRED - No authorization check#CHECK - Warning if no DCL exists#MANDATORY - Error if no DCL exists#NOT_ALLOWED - DCL ignored if existsComplete Reference: See references/access-control-reference.md for detailed DCL patterns.
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.
SELECT * FROM zcds_example
WHERE field1 = @lv_value
INTO TABLE @DATA(lt_result).
cl_salv_gui_table_ida=>create_for_cds_view(
CONV #( 'ZCDS_EXAMPLE' )
)->fullscreen( )->display( ).
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
}
Problem: Cardinality doesn't match actual data
Solution: Define cardinality matching data model
association [0..1] to ... -- Use for optional relationships
association [1..*] to ... -- Use for required one-to-many
For complete troubleshooting guide, see references/troubleshooting.md.
CL_DD_DDL_ANNOTATION_SERVICE - Programmatic annotation access:
get_annos() - Get all annotationsget_label_4_element() - Get @EndUserText.labelFor detailed guidance, see the reference files in references/:
annotations-reference.md - Complete annotation catalogfunctions-reference.md - All built-in functions with examplesassociations-reference.md - Associations and cardinality guideaccess-control-reference.md - DCL and authorization patternsexpressions-reference.md - Expressions and operatorstroubleshooting.md - Common errors and solutionsFor templates, see templates/:
basic-view.md - Standard CDS view templateparameterized-view.md - View with input parametersdcl-template.md - Access control definitionUpdate this skill by checking:
Last Verified: 2025-11-23
This skill should be used when the user asks to "create a slash command", "add a command", "write a custom command", "define command arguments", "use command frontmatter", "organize commands", "create command with file references", "interactive command", "use AskUserQuestion in command", or needs guidance on slash command structure, YAML frontmatter fields, dynamic arguments, bash execution in commands, user interaction patterns, or command development best practices for Claude Code.
This skill should be used when the user asks to "create an agent", "add an agent", "write a subagent", "agent frontmatter", "when to use description", "agent examples", "agent tools", "agent colors", "autonomous agent", or needs guidance on agent structure, system prompts, triggering conditions, or agent development best practices for Claude Code plugins.
This skill should be used when the user asks to "create a hook", "add a PreToolUse/PostToolUse/Stop hook", "validate tool use", "implement prompt-based hooks", "use ${CLAUDE_PLUGIN_ROOT}", "set up event-driven automation", "block dangerous commands", or mentions hook events (PreToolUse, PostToolUse, Stop, SubagentStop, SessionStart, SessionEnd, UserPromptSubmit, PreCompact, Notification). Provides comprehensive guidance for creating and implementing Claude Code plugin hooks with focus on advanced prompt-based hooks API.