Scripting Example 1: Use OData Actions in Analytics Designer or Optimized Story Experience

As an application designer or story developer, you can let viewers execute OData (V4) actions within an analytic application or optimized story, which are exposed by a connected on-premise SAP S/4HANA system.

Prerequisites

You've created an analytic application or optimized story and added an OData service to it.

Context

In this example, there're following elements for ODataService_1:

  • The system: FUB

  • The end-point URL for the OData service

  • As metadata, the OData version and two actions, Flight/Book and CancelMyFlights

Procedure

  1. Add a button widget.
  2. In the Properties section of the button's Styling panel, change the text to Cancel Flight.
  3. Select in the quick actions menu of the widget to open the script editor.

    You'd like to write a script to trigger execution of the OData action in the source system.

  4. In the script editor, do the following:
    1. Type the name of the OData service you've added and specified, ODataService_1, followed by ..
    2. Press CTRL + Space , and the script editor assists you with code completion and value help wherever possible. Select the function executeAction().
    3. Place the mouse cursor between the brackets ( () ), press CTRL + Space , and then select action CancelMyFlights from the value help of executeAction(), followed by , and {}.
    4. Place the mouse cursor between the brackets ({}), press CTRL + Space , and select the parameter DateFrom from value help, followed by : .
    5. Type the date 2019-01-01, followed by ,.
    6. Press CTRL + Space , and select DateTo from value help, folllowed by :.
    7. Type in the date 2019-12-31, and finish with ;.

    You've created a script to execute an OData action. This action has a simple syntax with two parameters and looks like this:

    ODataService_1.executeAction("CancelMyFlights", {DateFrom: "2019-01-01", DateTo: "2019-12-31"}); 
  5. Insert another button, rename it to Book Flight in the Styling panel, and open the script editor.

    The BookFlight Action is a bound action, which is more complex than the first one.

  6. Type the following script in the script editor by using code completion and value help:
    ODataService_1.executeAction("Flight/Book", {Flight:{Airline:"UA",Flightconnection:"0941", Flightdate: "2019-01-05"},NumberOfSeats: 1}); 

Results

You've configured a simple OData action. Now you can run your application or story, and book and cancel flights for the selected values.

You can enhance your application or story and start using other script methods to fill the parameter values dynamically with local or global variables.

Finally, you can make the response from the back end system visible in the application or story via a text field. To find out more details, see Scripting Example 2: Use OData Actions in Analytics Designer or Optimized Story Experience.