All skills
secondsky avatar

/sap-sac-scripting

@620a19a
by Eddiesecondsky/sap-skills456 stars
120

Comprehensive SAC scripting skill for SAP Analytics Cloud Analytics Designer and Optimized Story Experience. This skill should be used when the user asks to "create SAC script", "debug Analytics Designer", "optimize SAC performance", "planning operations in SAC", "filter data in SAC", "use DataSource API", "chart scripting", "table manipulation", "SAC event handlers", "version management", "data locking", "Optimized Story Experience API", "OSE scripting", "OSE widget API", "OSE DataSource", "story scripting API", "OSE planning API", "OSE method", "optimized story", "SAC story scripting", "story script", "SAC scripting", "debug SAC runtime in Microsoft Edge via CDP", or works with SAC widgets, planning models, or analytics applications.

Use this Skill: https://skilld.dev/gh/secondsky/sap-skills/sap-sac-scripting

This session only. Nothing lands on disk.

referenceschart-variance-apis.md

≈1.2k tokens on demand. Your agent reads this file only when SKILL.md points to it.

Chart Variance Script APIs

New in SAC Q4 2025 (2025.21): Script APIs for managing chart variances programmatically.


Overview

Chart variance APIs allow developers to dynamically add, remove, update, and retrieve variance configurations on charts in the optimized story experience.

Availability: Optimized Story Experience (Q4 2025+) Widget Types: Bar Chart, Column Chart, Line Chart, Combo Chart


API Reference

getVariances()

Get all configured variances on a chart.

var variances = Chart_1.getVariances();

// Returns array of variance objects
variances.forEach(function(v) {
    console.log("Variance:", v.id, v.referenceMeasure, v.comparisonMeasure);
});

Returns: Array<Variance>

addVariance(options)

Add a new variance to the chart.

Chart_1.addVariance({
    referenceMeasure: "Actual",
    comparisonMeasure: "Budget",
    varianceType: VarianceType.Absolute,
    showLabel: true,
    position: VariancePosition.Right
});

Parameters:

Parameter Type Required Description
referenceMeasure string Yes Measure to compare from
comparisonMeasure string Yes Measure to compare to
varianceType VarianceType No Absolute, Percentage, or Both
showLabel boolean No Show variance label
position VariancePosition No Left, Right, Top, Bottom
color string No Variance indicator color

updateVariance(varianceId, options)

Update an existing variance configuration.

// Toggle to percentage display
Chart_1.updateVariance("var_001", {
    varianceType: VarianceType.Percentage,
    showAsPositiveGreen: true
});

removeVariance(varianceId)

Remove a variance from the chart.

Chart_1.removeVariance("var_001");

removeAllVariances()

Remove all variances from the chart.

Chart_1.removeAllVariances();

Enumerations

VarianceType

VarianceType.Absolute      // Show absolute difference
VarianceType.Percentage    // Show percentage difference
VarianceType.Both          // Show both absolute and percentage

VariancePosition

VariancePosition.Left
VariancePosition.Right
VariancePosition.Top
VariancePosition.Bottom
VariancePosition.Inline    // Inline with data label

Common Patterns

Dynamic Variance Toggle

// Toggle button onClick
var variances = Chart_1.getVariances();

if (variances.length > 0) {
    // Remove existing variance
    Chart_1.removeAllVariances();
    Button_Toggle.setText("Show Variance");
} else {
    // Add variance
    Chart_1.addVariance({
        referenceMeasure: "Actual",
        comparisonMeasure: "Plan",
        varianceType: VarianceType.Both
    });
    Button_Toggle.setText("Hide Variance");
}

Conditional Variance Display

// Show variance only for specific dimension members
var selections = Chart_1.getSelections();

if (selections.length > 0 && selections[0]["Category"] === "Revenue") {
    Chart_1.addVariance({
        referenceMeasure: "Current Year",
        comparisonMeasure: "Prior Year",
        varianceType: VarianceType.Percentage
    });
}

Variance Based on Dropdown Selection

// Dropdown onChange event
var selectedComparison = Dropdown_Comparison.getSelectedKey();

Chart_1.removeAllVariances();

if (selectedComparison !== "none") {
    Chart_1.addVariance({
        referenceMeasure: "Actual",
        comparisonMeasure: selectedComparison,
        varianceType: VarianceType.Absolute
    });
}

Event: onVarianceChange

Fires when variance configuration changes.

// In Chart_1 onVarianceChange event
var changeInfo = event.getChangeInfo();

console.log("Variance changed:", changeInfo.type); // "added", "updated", "removed"
console.log("Variance ID:", changeInfo.varianceId);

// Update status text
Text_Status.setText("Variance " + changeInfo.type);

Export Considerations

When exporting charts with variances:

Application.exportToPDF({
    includeVariance: true,
    varianceFormat: "inline" // or "separate_column"
});

Best Practices

  1. Check Measures Exist: Verify measures are available before adding variance
  2. Clear Before Adding: Use removeAllVariances() before adding new ones to avoid duplicates
  3. Provide User Feedback: Show busy indicator during variance recalculation
  4. Consider Mobile: Test variance display on mobile devices

Version: Q4 2025 (2025.21) Last Updated: 2025-12-27

Source: SKILL.md on GitHub

1 alert16d5 checks · Risk SAFE
  • Gen Agent Trust Hub16d

    The skill is a comprehensive reference and template collection for SAP Analytics Cloud (SAC) scripting. It provides secure instructions for setting up an associated Model Context Protocol (MCP) server, including commit pinning and security flags during installation. It also incorporates multiple security best practices for developers, such as origin validation for iframe communication.

  • Socket16d

    1 alert: gptAnomaly

  • Snyk16d

    Risk: MEDIUM · 1 issue

  • Runlayer6mo

    32/61 files flagged

  • ZeroLeaks5mo

    Score: 93/100 · 2 sections analyzed

Signed by skilld at 620a19a. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub 2 weeks ago.

Activeupdated 2 months ago
Other metadata
metadata
{
  "maintainer": "Eduard Jiglau",
  "maintainer_email": "hello@sap-ai-skills.com",
  "website": "https://sap-ai-skills.com",
  "version": "2.4.1",
  "last_verified": "2026-06-11",
  "sac_version": "Q2 2026 (2026.8)",
  "api_reference_version": "2025.20 (OSE Q2 2026)",
  "documentation_source": "https://help.sap.com/docs/SAP_ANALYTICS_CLOUD",
  "reference_files": 66,
  "template_patterns": 56,
  "agents": 4,
  "commands": 4,
  "status": "docs_audited_runtime_pending",
  "known_issues": [
    "Live SAC story/runtime checks require tenant evidence before claiming production validation."
  ]
}

README badge

README badge for secondsky/sap-skills/sap-sac-scripting