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
-
Add a button widget.
-
In the Properties section of the button's Styling panel, change the text to
Cancel Flight.
-
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.
-
In the script editor, do the following:
-
Type the name of the OData service you've added and specified, ODataService_1, followed by
..
-
Press
CTRL
+ Space
, and the script editor assists you with code completion and value help wherever possible. Select the function
executeAction().
-
Place the mouse cursor between the brackets ( () ), press
CTRL
+ Space
, and then select action CancelMyFlights from the value help of
executeAction(), followed by , and {}.
-
Place the mouse cursor between the brackets ({}), press
CTRL
+ Space
, and select the parameter DateFrom from value help, followed by :
.
-
Type the date 2019-01-01, followed by ,.
-
Press
CTRL
+ Space
, and select DateTo from value help, folllowed by :.
-
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"});
-
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.
-
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.