$120 tested Claude codes · real before/after data · Full tier $15 one-timebuy --sheet=15 →
$Free 40-page Claude guide — setup, 120 prompt codes, MCP servers, AI agents. download --free →
clskills.sh — terminal v2.4 — 2,347 skills indexed● online
[CL]Skills_
SAPadvancedNew

SAP S/4 Embedded Analytics

Share

Build CDS-based analytical queries and KPI tiles for S/4HANA

Works with OpenClaude

You are an SAP S/4HANA analytics developer. The user wants to build CDS-based analytical queries and create KPI tiles for embedded analytics in S/4HANA.

What to check first

  • Verify CAP framework is installed: npm list @sap/cds (minimum version 5.0+)
  • Confirm db/ and srv/ directories exist in your CAP project structure
  • Check mta.yaml or package.json has @sap/cds-dk in devDependencies
  • Ensure S/4HANA data source is configured in your destination settings for local development

Steps

  1. Create a CDS analytical data model in db/analytics/ by defining an entity with @Analytics annotation specifying measures and dimensions
  2. Add @Aggregation and @AnalyticsDetails annotations to mark numeric fields as measures and text fields as dimensions
  3. Define a CDS query using define view with explicit measure and dimension columns, applying @EndUserText.label annotations
  4. Create an OData service endpoint in srv/ that exposes the CDS view with @cds.persistence: { skip: true } to query transactional S/4HANA tables
  5. Use @Analytics.query: true on the service definition to enable analytics-specific OData behavior
  6. Build KPI tile metadata by adding @UI.KPI annotations specifying criticality thresholds and target values
  7. Deploy to SAP Cloud Platform or on-premise S/4HANA with cds deploy and verify the service is accessible
  8. Test the analytical query with OData $apply parameters: SUM(Amount) by Company_Code to validate aggregation

Code

// db/analytics/financial-kpi.cds
namespace sap.analytics;

using { sap.s4.transactions as transactional } from '../data-model';

define entity FinancialMetrics {
  key CompanyCode: String;
  key FiscalYear: Integer;
  key CostCenter: String;
  
  // Dimensions
  CompanyName: String;
  ControllingArea: String;
  
  // Measures
  TotalRevenue: Decimal(15,2);
  TotalCost: Decimal(15,2);
  GrossProfit: Decimal(15,2);
  ProfitMargin: Decimal(5,2);
}

// db/analytics/revenue-query.cds
define view RevenueAnalysis as
  select from transactional.SalesOrders {
    key SalesOrg as SalesOrganization,
    key CreatedMonth as Month,
    
    SalesOrg @Analytics.dimension: true
      @EndUserText.label: 'Sales Organization',
    CreatedMonth @Analytics.dimension: true
      @EndUserText.label: 'Month',
    CustomerSegment @Analytics.dimension:

Note: this example was truncated in the source. See the GitHub repo for the latest full version.

Common Pitfalls

  • Treating this skill as a one-shot solution — most workflows need iteration and verification
  • Skipping the verification steps — you don't know it worked until you measure
  • Applying this skill without understanding the underlying problem — read the related docs first

When NOT to Use This Skill

  • When a simpler manual approach would take less than 10 minutes
  • On critical production systems without testing in staging first
  • When you don't have permission or authorization to make these changes

How to Verify It Worked

  • Run the verification steps documented above
  • Compare the output against your expected baseline
  • Check logs for any warnings or errors — silent failures are the worst kind

Production Considerations

  • Test in staging before deploying to production
  • Have a rollback plan — every change should be reversible
  • Monitor the affected systems for at least 24 hours after the change

Quick Info

CategorySAP
Difficultyadvanced
Version1.0.0
AuthorClaude Skills Hub
saps4hanaanalytics

Install command:

curl -o ~/.claude/skills/sap-s4-embedded-analytics.md https://clskills.in/skills/sap/sap-s4-embedded-analytics.md

Related SAP Skills

Other Claude Code skills in the same category — free to download.

Want a SAP skill personalized to YOUR project?

This is a generic skill that works for everyone. Our AI can generate one tailored to your exact tech stack, naming conventions, folder structure, and coding patterns — with 3x more detail.