### Planning Examples Source: https://help.sap.com/docs/SAP_ANALYTICS_CLOUD/00f68c2e08b941f081002fd3691d86a7/73fbf0e96c054d7aa58c404addeeaab4.html?locale=en-US&state=PRODUCTION&version=release Examples demonstrating how to use setUserInput and submitData APIs for planning cells. ```APIDOC ## Example ### Planning a cell with a selection object ```javascript Table_1.getPlanning().setUserInput({}, "5000000"); Table_1.getPlanning().submitData(); ``` ### Planning a cell with a selection from the table ```javascript Table_1.getPlanning().setUserInput(Table_1.getSelections()[0], "500000000.99"); Table_1.getPlanning().submitData(); ``` ### Planning a cell with the value from an input field ```javascript Table_1.getPlanning().setUserInput({}, InputField_1.getValue()); Table_1.getPlanning().submitData(); ``` ``` -------------------------------- ### Start Edit Mode on All Data (Actual Version) Source: https://help.sap.com/docs/SAP_ANALYTICS_CLOUD/00f68c2e08b941f081002fd3691d86a7/3ab1bcb462a9490fb56c63715afbc879.html?locale=en-US&state=PRODUCTION&version=release This script example demonstrates how to start edit mode on all data for the 'Actual' version using the PlanningPublicEditOption.AllData. ```typescript PlanningModel_1.getPublicVersion("Actual").startEditMode(PlanningPublicEditOption.AllData); ``` -------------------------------- ### Start Edit Mode on Customized Planning Area with Filters Source: https://help.sap.com/docs/SAP_ANALYTICS_CLOUD/00f68c2e08b941f081002fd3691d86a7/3ab1bcb462a9490fb56c63715afbc879.html?locale=en-US&state=PRODUCTION&version=release This example shows how to start edit mode on a customized planning area for a table. It involves retrieving planning area information, modifying filters, and then applying them with the startEditMode API. ```typescript var PlanningAreaFilters = Table_1.getPlanning().getPlanningAreaInfo(); // Remove predefined Date dimension filter PlanningAreaFilters.removeFilter("Date"); // Change predefined filter. PlanningAreaFilters.changeFilter("GenericDimension", {"hierarchy":"H1","members":["[ GenericDimension].[H1].&[A]"]}); // Assign filter var filters = PlanningAreaFilters.getFilters(); // Start edit mode with CustomizedPlanningArea option and filters Table_1.getPlanning().getPublicVersion("Actual").startEditMode(planningPublicEditOption.CustomizedPlanningArea, filters ) ``` -------------------------------- ### Example JDBC Driver Properties File Source: https://help.sap.com/docs/SAP_ANALYTICS_CLOUD/00f68c2e08b941f081002fd3691d86a7/0d5ffbb6951b45778c1a90ffd0114f04.html?locale=en-US&state=PRODUCTION&version=release This file specifies the paths to JDBC drivers on the file system where the SAP BusinessObjects Cloud Agent is installed. Uncomment and provide paths for your specific database drivers. ```properties #This file is to specify where your JDBC drivers are on the file system of the machine where the SAP BusinessObjects Cloud Agent is installed #For each database you have a driver for, you can remove the # from before the name of the database and specify the path to the jar file #If a driver requires multiple jar files you can separate the paths with semicolons #This list corresponds to BOE 4.2 SP5 ``` -------------------------------- ### Using FIRST() with Employee Start Dates Source: https://help.sap.com/docs/SAP_ANALYTICS_CLOUD/00f68c2e08b941f081002fd3691d86a7/afe93e3cf1414a7b8419baad11cc066e.html?locale=en-US&state=PRODUCTION&version=release This example uses the FIRST() function to retrieve the first period of an employee's start date, considering the fiscal year configuration. It writes the data to the first period of the fiscal year. ```script CONFIG.TIME_HIERARCHY=FISCALYEAR MEMBERSET [d/Employee]=("E001","E002") DATA([d/Date1]=FIRST([d/Employee].[p/Startdate])) =RESULTLOOKUP() ``` -------------------------------- ### Timer Start API Syntax Source: https://help.sap.com/docs/SAP_ANALYTICS_CLOUD/00f68c2e08b941f081002fd3691d86a7/142a436d0f2a4e97a9af15853ca9b739.html?locale=en-US&state=PRODUCTION&version=release Use the start() API to initiate a timer. Specify the delay in seconds. ```javascript start(delayInSeconds: number) ``` -------------------------------- ### Example of Handling Upload Results Source: https://help.sap.com/docs/SAP_ANALYTICS_CLOUD/00f68c2e08b941f081002fd3691d86a7/c93a0c2aa5664e9ab3e8aff765f317ad.html?locale=en-US&state=PRODUCTION&version=release An example demonstrating how to use the onAfterExecute API to log the outcome of a data upload, including status and file name. ```typescript onAfterExecute( 'SUCCESS', 'Upload completed', { uploadedRowCount: 950, rejectedRowCount: 50 }, [['row1-col1', 'row1-col2'], ['row2-col1', 'row2-col2']], 'v2.1', 'customers.csv' ): void { // Handle the upload results console.log(`${fileName} uploaded with status: ${status}`); } ``` -------------------------------- ### Initialize Page and Start Timer Source: https://help.sap.com/docs/SAP_ANALYTICS_CLOUD/00f68c2e08b941f081002fd3691d86a7/142a436d0f2a4e97a9af15853ca9b739.html?locale=en-US&state=PRODUCTION&version=release This script runs on page initialization. It sets up margin values and image widgets, then starts the timer after a 3-second delay. ```javascript console.log('onInitialization - begin'); LeftMargins = [112, 240, 368]; Animation_Widgets = [Image_1,Image_2,Image_3]; //Start the timer after 3 seconds after initializing the page. Timer_1.start(3); console.log('onInitialization - end'); ``` -------------------------------- ### Using LAST() with Employee Start Dates Source: https://help.sap.com/docs/SAP_ANALYTICS_CLOUD/00f68c2e08b941f081002fd3691d86a7/afe93e3cf1414a7b8419baad11cc066e.html?locale=en-US&state=PRODUCTION&version=release This example uses the LAST() function to retrieve the last period of an employee's start date, considering the fiscal year configuration. It returns the last member of the fiscal year. ```script CONFIG.TIME_HIERARCHY=FISCALYEAR MEMBERSET [d/Employee]=("E001","E002") DATA()=RESULTLOOKUP([d/Date1]=LAST([d/Employee].[p/Startdate])) ``` -------------------------------- ### Start Data Provisioning Agent (Linux) Source: https://help.sap.com/docs/SAP_ANALYTICS_CLOUD/00f68c2e08b941f081002fd3691d86a7/14a4cca98d97445284cf085196c7173e.html?locale=en-US&state=PRODUCTION&version=release This command starts the Data Provisioning Agent configuration on a Linux host. Ensure the DPA_INSTANCE environment variable is set correctly beforehand. ```bash /bin/agentcli.sh --configAgent ``` -------------------------------- ### Start Data Provisioning Agent (Windows) Source: https://help.sap.com/docs/SAP_ANALYTICS_CLOUD/00f68c2e08b941f081002fd3691d86a7/14a4cca98d97445284cf085196c7173e.html?locale=en-US&state=PRODUCTION&version=release This command starts the Data Provisioning Agent configuration on a Windows host. Ensure the DPA_INSTANCE environment variable is set correctly beforehand. ```batch /bin/agentcli.bat --configAgent ``` -------------------------------- ### OData V4 Syntax Examples with Expand Source: https://help.sap.com/docs/SAP_ANALYTICS_CLOUD/00f68c2e08b941f081002fd3691d86a7/4c002a6b954d43f18f3712cb10ac3cdc.html?locale=en-US&state=PRODUCTION&version=release Illustrates OData V4 query syntax, specifically showcasing the use of the expand parameter for retrieving related data. Includes examples for KeyPredicate and FunctionImport. ```odata KeyPredicate: Products?$select=ID,Name,Description,ReleaseDate,DiscontinuedDate,Rating,Price&$expand=ProductDetail($select=ProductID),ProductDetail($select=Details) FunctionImport: GetNearestAirport(lat=80, lon=90) ``` -------------------------------- ### Start Data Provisioning Agent on Linux Source: https://help.sap.com/docs/SAP_ANALYTICS_CLOUD/00f68c2e08b941f081002fd3691d86a7/14a4cca98d97445284cf085196c7173e.html?locale=en-US&state=PRODUCTION&version=release Use this command to start the Data Provisioning Agent on a Linux system. This is typically required after making configuration changes. ```bash /bin/agentcli.sh --setSecureProperty ``` -------------------------------- ### Get Distinct Product Members using getDataSelections and getResultMember Source: https://help.sap.com/docs/SAP_ANALYTICS_CLOUD/00f68c2e08b941f081002fd3691d86a7/834786949212459caabe3a3d13f0aaa9.html?locale=en-US&state=PRODUCTION&version=release Example demonstrating how to retrieve unique product member IDs from selected data in a table widget. ```javascript // Get distinct product member of the table widget var selections = Table_1.getDataSource().getDataSelections(); var memberIds = ArrayUtils.create(Types.string); for (var i = 0; i < selections.length; i++) { var member = Table_1.getDataSource().getResultMember("Product_1", selections[i]); if (member && member.id && memberIds.indexOf(member.id) < 0) { memberIds.push(member.id); } } ``` -------------------------------- ### FIRST() with Day Granularity Examples Source: https://help.sap.com/docs/SAP_ANALYTICS_CLOUD/00f68c2e08b941f081002fd3691d86a7/afe93e3cf1414a7b8419baad11cc066e.html?locale=en-US&state=PRODUCTION&version=release Provides examples of the FIRST() function with 'DAY' granularity, showing its output for 'MONTH', 'QUARTER', and 'YEAR' granularities when applied to a specific date. ```script FIRST("2025-05-02", "MONTH") returns "2025-05-01" ``` ```script FIRST("2025-05-02", "QUARTER") returns "2025-04-01" ``` ```script FIRST("2025-05-02", "YEAR") returns "2025-01-01" ``` -------------------------------- ### Counting Entities in an OData Set Source: https://help.sap.com/docs/SAP_ANALYTICS_CLOUD/00f68c2e08b941f081002fd3691d86a7/05a5e8a72280470e9e6c174c35bc993a.html?locale=en-US&state=PRODUCTION&version=release Shows how to get the total count of entities within an OData entity set, with an example of applying skip and top options. ```javascript // returns the number of entities in the entity set "TEAMS" ODataService_2.getEntitiesCountFromEntitySet("TEAMS"); // returns the number of entities in the entity set "EMPLOYEES", filtered by the given system query option(s) ODataService_2.getEntitiesCountFromEntitySet("EMPLOYEES", {skip: 5, top: 10}); ``` -------------------------------- ### Basic Navigation Examples Source: https://help.sap.com/docs/SAP_ANALYTICS_CLOUD/00f68c2e08b941f081002fd3691d86a7/62979224ad9a4091a7cca922063c5216.html?locale=en-US&state=PRODUCTION&version=release Demonstrates how to use NavigationUtils to open a story, an application, and create URLs for them. It's recommended to specify the 'mode' parameter, such as 'embed', for consistent behavior. ```typescript NavigationUtils.openStory("story_id", "page_id", UrlParameter.create('mode','embed'),false); NavigationUtils.openApplication("application_id", UrlParameter.create('mode','embed'),false); NavigationUtils.createStoryUrl("story_id", "page_id", UrlParameter.create('mode','embed')); NavigationUtils.createApplicationUrl("application_id", UrlParameter.create('mode','embed')); ``` -------------------------------- ### Get Calendar Event Status Source: https://help.sap.com/docs/SAP_ANALYTICS_CLOUD/00f68c2e08b941f081002fd3691d86a7/a727e860122944b0be6a8351456174f8.html?locale=en-US&state=PRODUCTION&version=release Retrieve the overall status of a calendar event using the `getStatus` API. This example demonstrates how to log the status based on predefined `CalendarTaskStatus` enum values. ```javascript var status = CalendarIntegration_1.getCurrentEvent().getStatus(); switch (status) { case CalendarTaskStatus.InProgress: console.log("In Progress"); break; case CalendarTaskStatus.Canceled: console.log("Canceled"); break; case CalendarTaskStatus.OnHold: console.log("OnHold"); break; case CalendarTaskStatus.Open: console.log("Open"); break; } ``` -------------------------------- ### Analytics Designer/Story Script Usage Source: https://help.sap.com/docs/SAP_ANALYTICS_CLOUD/0ac8c6754ff84605a4372468d002f2bf/bde41c0b637b49fbb4e7904b660b094f.html?locale=en-US&state=PRODUCTION&version=release Demonstrates how to use the custom widget's 'put' and 'get' methods in an Analytics Designer or Story script. This example adds two numbers and retrieves one. ```javascript var number1 = 1; var number2 = 2; customWidget.put("n1", number1); customWidget.put("n2", number2); var n = customWidget.get("n2"); ``` -------------------------------- ### Start Data Provisioning Agent on Windows Source: https://help.sap.com/docs/SAP_ANALYTICS_CLOUD/00f68c2e08b941f081002fd3691d86a7/14a4cca98d97445284cf085196c7173e.html?locale=en-US&state=PRODUCTION&version=release Use this command to start the Data Provisioning Agent on a Windows system. This is typically required after making configuration changes. ```batch /bin/agentcli.bat --setSecureProperty ``` -------------------------------- ### Example URL with isOVM Parameter Source: https://help.sap.com/docs/SAP_ANALYTICS_CLOUD/00f68c2e08b941f081002fd3691d86a7/e717d4d999fc45f8bc478f93a6fe0e9d.html?locale=en-US&state=PRODUCTION&version=release Use this URL parameter to indicate if optimized view mode is enabled for your story or analytic application, accelerating initial loading. This parameter is effective only when optimized story experience features are available on your tenant. ```url https:///sap/fpa/ui/tenants//app.html#/story&/s//?isOVM=true ``` -------------------------------- ### New ELSEIF Behavior Example Source: https://help.sap.com/docs/SAP_ANALYTICS_CLOUD/00f68c2e08b941f081002fd3691d86a7/afe93e3cf1414a7b8419baad11cc066e.html?locale=en-US&state=PRODUCTION&version=release Demonstrates the updated ELSEIF logic starting from version 2021.02, where overlapping data scopes are excluded. This script sets member sets for Date, Region, and Flow, then applies conditional logic with IF and ELSEIF statements. ```script MEMBERSET [d/Date] = ("201801","201812") MEMBERSET [d/Region] = ("EUR","USA") MEMBERSET [d/Flow] = ("Open","Close") IF [d/Date] = "201801" THEN DATA() = 100 ELSEIF [d/Region] = "EUR" THEN DATA() = 200 ELSEIF [d/Flow] = "Close" THEN DATA() = 300 ELSE DATA() = 400 ENDIF ``` -------------------------------- ### Calculate Revenue using LINK Function Source: https://help.sap.com/docs/SAP_ANALYTICS_CLOUD/00f68c2e08b941f081002fd3691d86a7/afe93e3cf1414a7b8419baad11cc066e.html?locale=en-US&state=PRODUCTION&version=release This example demonstrates calculating revenue by linking data from a 'Sales Planning' model to a 'Financial' model. It specifies member sets for dimensions and uses the LINK function to retrieve sales measures. ```script MEMBERSET [d/Measures] = "Amount" MEMBERSET [d/Date] = "202601" TO "202612" MEMBERSET [d/Entity_D] = "US" MEMBERSET [d/BusinessUnit] = "BU_SKU" MEMBERSET [d/ProductGroup] = "SKU" MODEL [Sales Planning] // Product_Item and Sales_Channel only exist in the linked source model Sales but not in default model Financial. They are used to define the source model scope. MEMBERSET [d/Product_Item] = ("SKU_001", "SKU_002", "SKU_003", "SKU_004", "SKU_005") MEMBERSET [d/Sales_Channel] = ("Direct", "Online", "Retail") //Since the Date dimension is not a shared dimension, you need to define the Date scope of the source model. MEMBERSET [d/Date] = "202601" TO "202652" ENDMODEL //33001000 stands for Revenue Domestic-Product. // The granularities of the Date dimensions are different, adding syntax "[d/Date] = PERIOD([Sales Planning].[d/Date] " to accommodate for the difference. DATA([d/Account_Fin] = "33001000", [d/DataSrc] = "DataSrc_Sales", [d/Date] = PERIOD([Sales Planning].[d/Date])) = LINK([Sales Planning], [d/Measures] = "S90007000", [d/Version] = "public.Plan01") * LINK([Sales Planning], [d/Measures] = "S90008000", [d/Version] = "public.Plan01") ``` -------------------------------- ### SAP Analytics Cloud Tab Strip Scripting Examples Source: https://help.sap.com/docs/SAP_ANALYTICS_CLOUD/00f68c2e08b941f081002fd3691d86a7/e0b40c5da2fd4a468353f96e13ebb6fb.html?locale=en-US&state=PRODUCTION&version=release These scripts demonstrate how to get the selected tab's key, acquire a specific tab's key, and change a tab's text using the Tab Strip API. ```javascript // Returns the key of the selected tab and adds it to Dropdown_1. var selectedTabKey = TabStrip_1.getSelectedKey(); Dropdown_1.addItem(selectedTabKey); // Returns the key of the specified tab Tab_1 and adds it to Dropdown_1. var tabKey = TabStrip_1.getTab("Tab_1").getKey(); Dropdown_1.addItem(tabKey); // Change the text of the specified tab Tab_1 to "New Text". TabStrip_1.getTab("Tab_1").setText("New Text"); ``` -------------------------------- ### FOREACH.BOOKED Example for Sales Rebates Source: https://help.sap.com/docs/SAP_ANALYTICS_CLOUD/00f68c2e08b941f081002fd3691d86a7/afe93e3cf1414a7b8419baad11cc066e.html?locale=en-US&state=PRODUCTION&version=release Repeats statements for each dimension combination with values, enhancing performance. This example calculates sales rebates based on past sales amounts. ```SAP Analytics Cloud Script FLOAT @sumOfProduct MEMBERSET [d/Date] = "201801" TO "201812" MEMBERSET [d/Customer] = ("CUST001", "CUST002") FOREACH.BOOKED [d/Customer], [d/Date] @sumOfProduct = RESULTLOOKUP([d/Account] = "SweaterRevenue") IF @sumOfProduct < 5000 THEN DATA([d/Account] = "SalesRebateRatio", [d/Date] = NEXT(12)) = 0.8 ENDIF ENDFOR ``` -------------------------------- ### Example: Timed Refresh of Widget Data Source: https://help.sap.com/docs/SAP_ANALYTICS_CLOUD/00f68c2e08b941f081002fd3691d86a7/619bf4d9eb194036a538314aa103d9c0.html?locale=en-US&state=PRODUCTION&version=release This script uses the refresh data API in conjunction with a timer's onTimeout event to refresh data for specific charts (Chart_1 and Chart_2) every minute. Ensure the timer is started using Timer_1.start(60);. ```javascript Chart_1.getDataSource().refreshData(); Chart_2.getDataSource().refreshData(); Timer_1.start(60); ``` -------------------------------- ### Example allowlist.txt Content Source: https://help.sap.com/docs/SAP_ANALYTICS_CLOUD/00f68c2e08b941f081002fd3691d86a7/a8435da6970041d2beb3299cdcff7026.html?locale=en-US&state=PRODUCTION&version=release Specifies a sample format for the allowlist file, indicating a network path for import operations. Ensure the path format matches your operating system (Windows or Linux). ```text \\\Import ``` -------------------------------- ### Verify Java Development Kit (JDK) Installation Source: https://help.sap.com/docs/SAP_ANALYTICS_CLOUD/00f68c2e08b941f081002fd3691d86a7/2c46bd832eb543fbb22d8cc3ffaf6e1f.html?locale=en-US&state=PRODUCTION&version=release Checks if a compatible version of the Java Development Kit (JDK) is installed and accessible. This command is used after installing Oracle JDK 8 or SAP JDK 8. ```bash javac -version ```