SAP SAC Document Design
SAP SAC Document Design
Introduction .................................................................................................................... 13
1 Introduction to Scripting 17
7 7
Contents Contents
8 8
ContentsContents
9 9
Contents Contents
10 10
ContentsContents
7 Outlook 267
Appendices 271
11 11
Chapter 6
Provision and Operation Stories with
Scripting
This chapter looks at various options for providing stories in general, the
6
enhancement of stories through scripting, and operational issues such as
performance monitoring and notifications of updated data.
In Section 6.1, “Sharing Stories within SAP Analytics Cloud,” we’ll look with What you can
you at the various options for sharing stories with other users. You can expect
share stories via the file system or via the SAP Analytics Cloud catalog, and
there are additional setting options for the mobile app. In Section 6.2,
“Embedding Stories in Websites, we’ll explain how you can embed your
story in other websites. Section 6.3, “Performance Monitoring,” takes up a
large part of this chapter and is dedicated to performance monitoring.
Since scripting is much more complex and specialized than simple stories,
performance problems are more likely to occur. Finally, in Section 6.4, “Best
Practices for Performance,” we provide some onboard tools and options for
detecting and limiting potential performance problems.
241 241
6 Provision and Operation Stories with Scripting 6 Provision and Operation Stories with Scripting
242 242
6 Provision6.1
andSharing
Operation Stories
Stories withSAP
within Scripting
Analytics Cloud
If you share a story in the file system, you also have the option of customiz-
ing the URL to be shared by using the Customize link button.
You can enter URL parameters and partially replace the URL with keywords Creating your own
so that it’s shorter and therefore easier to remember. You can see an exam- URL
You also have the option of informing the recipient by email about sharing
the application or specifying a global bookmark as the default. As the appli-
cation designer, you can also give your users the option of opening the
dialog box for sharing the runtime:
Application.openShareApplicationDialog();
Analytics Catalog
You can also share your story via the analytics catalog of SAP Analytics Share stories with
Cloud. This can be activated by your administrator, and if it’s activated, the analytics
catalog
you’ll find a corresponding Catalog tab on your start page (see Figure 6.4).
The catalog is the central access point within SAP Analytics Cloud. You can
customize the individual catalog tiles, add tabs, and define your own filter
criteria.
243 243
6 Provision and Operation Stories with Scripting 6 Provision and Operation Stories with Scripting
If you want to publish your story in the catalog, you can release it at team
level but not at user level. You can also specify whether you want to grant
or deny read access (see Figure 6.5), which has the following effects:
Granting read access
If you grant read access, teams with it can open the tile and the story
behind it.
Denying read access
If you deny read access, users from the team will see the tile in your cat-
alog but won’t be able to access the story. However, they can send access
requests to you via this tile.
244 244
6 Provision6.1
andSharing
Operation Stories
Stories withSAP
within Scripting
Analytics Cloud
Publication of Stories
6
Another way to share your story is to publish it. This involves converting Sending story
your story into a PDF document and sending it by email to SAP Analytics
Cloud users and external persons.
The frequency of the possible dispatch times depends on your licensed
number of SAP Analytics Cloud users. You can check the current number of
available releases in your system overview (see Figure 6.6).
To be able to use this function in your story, you must create a technical
object for PDF export (see Figure 6.7). In this object, you can select the
included widgets and make the following general settings:
245 245
6 Provision and Operation Stories with Scripting 6 Provision and Operation Stories with Scripting
Name field
You can use this field to assign a name to the exported file.
Paper Size field
This field allows you to choose between predefined sizes, or you can use
the Automatic option.
Orientation field
This field allows you to choose between landscape and portrait format.
Page Details field
You can use this field to select whether page numbers should be dis-
played and, if so, whether they should be displayed in the header or
footer.
Enable Export in the Background indicator
You can use this indicator to decide whether the export should take
place in the background. This may result in longer waiting times.
Fully Display the Exported Widgets indicator
You can use this indicator to activate printing as a report. Only the table
is currently supported. You can also decide whether you want to activate
the Header, Footer, Appendix, and Comments elements.
246 246
6 Provision6.1
andSharing
Operation Stories
Stories withSAP
within Scripting
Analytics Cloud
To send a story via a publication, you have the following two setting options,
which can be found in the Format section of your graphics area (see Figure
6.8):
Automatically generate PDF export
This option is the default setting, in which the PDF document is gener-
ated automatically as soon as the rendering of the story has been com-
pleted. A story is fully rendered as soon as the last line of the 6
onInitialization event has been executed. With this option, you don’t
need to write a script.
Manually generate PDF export via API
You can use this option if you want to make advanced settings with
scripts and control the time of the export more precisely. Here, you can,
for example, insert a script in your onInitialization event at the desired
point:
if (Application.isRunBySchedulePublication()) {
Scheduling.publish();
}
Mobile App
In addition to using the aforementioned three options, you can make your
story available in a mobile app.
Translation
If you share your story with many different people, it’s likely that you’ll
want to make it available in different languages. This option is available to
you for your story.
To enable translation for a story, you must activate the Enable translation
switch in the story details (see Figure 6.9).
247 247
6 Provision and Operation Stories with Scripting 6 Provision and Operation Stories with Scripting
As soon as you activate this option, you’ll find your story in the Translation
menu of SAP Analytics Cloud, and you can store the desired translations for
the various elements (see Figure 6.10).
Scope of a Translation
Please note that only the elements of the story are translated; you must
configure the translation of your data in your data source.
248 248
6 Provision6.1
andSharing
Operation Stories
Stories withSAP
within Scripting
Analytics Cloud
There are two different ways of transporting objects between the different
systems in SAP Analytics Cloud, and we’ll look at them in more detail in the
following sections. You can find both options in your SAP Analytics Cloud
menu under Transport, where you have an area for Export and another area
for Import (see Figure 6.11).
Storage Space
A system can store up to 300 MB of exported content free of charge.
You must first create a new export. To do this, go to the Transport • Export
path and create a new package there in the Content network storage area,
using the + icon. You can now select which content should be included in
the package (see Figure 6.12).
In the next step, you can enter a name, a description, and detailed informa-
tion for your package. The destinations of this content are also defined
here, where you can set which accesses each target should have (see Figure
6.13).
249 249
6 Provision and Operation Stories with Scripting 6 Provision and Operation Stories with Scripting
In the last step, you’ll receive another overview of your content and set-
tings so that you can check them. If everything is set correctly, you can start
your export.
250 250
6 Provision6.1
andSharing
Operation Stories
Stories withSAP
within Scripting
Analytics Cloud
You can track the progress of each export in your notifications. As soon as
the export is complete, you’ll receive a notification.
To import the content in this way, select Import under Transport. Here,
you’ll see all available content, as well as the name and a description of the
content plus the URL of the tenant that provides the content (see Figure
6.14).
When you select content, you have the same options that you already know 6
from importing from the public content network.
Selectable Contents
You can only access the public folder in the Files area.
251 251
6 Provision and Operation Stories with Scripting 6 Provision and Operation Stories with Scripting
252 252
6 Provision and Operation Stories withStories
6.2 Embedding Scripting
in Websites
as a trusted source address, and you can find the corresponding settings
under System Administration • App Integration • Trusted Origin Addresses.
You can now trigger communication between the HTML page and the story.
To do this, use the postMessage method:
Hosting Website
Processes Messages
Embedded Story
Transmits Messages
You can also use the onPostMessageReceived event to process messages that
have been sent from the hosted website.
Hosting Application
Bidirectional
Web Application
Communication
You can use the postMessage method to send messages from your story to
the web application:
253 253
6 Provision and Operation Stories with Scripting 6 Provision and Operation Stories with Scripting
If you send the messages via the hosting story, their processing depends on
the embedded application:
In an SAP Analytics Cloud application, the receipt is processed via the
onPostMessageReceived event.
In a web application, you can process the message via the win-
dow.on("message") event.
254 254
6 Provision and Operation Stories with Scripting
6.3 Performance Monitoring
Start
6
Start
To find the point at which you can or should make optimizations, go Making
through the decision path. There are three main categories in which there optimizations
may be a need for optimization:
Browser, story, application, or planning process
Network
Backend
If the front-end time is particularly high, you should first check your
browser and client. Check whether the problem persists once you’ve closed
all other tabs and applications. Are you using a virtual machine? If so, check
whether the problem also exists on a physical computer. Your bandwidth
or a third-party proxy can also have a negative impact.
Once you’ve made sure that the slow performance is not due to your browser
or client, you should take a look at your story. If you’ve acted in accordance
with best practices, or if, for example, a large number of widgets are already
loaded when the story is initialized, then even though they are not needed
here, you should optimize them and just load the needed widgets.
If the network time is particularly high, you should check your reverse Network
proxy, the VPN, and your network. If possible, check whether the problem
is reproducible if you access the network without a VPN. Problems in your
SAP data center can also lead to delays, so check the status in SAP Trust Cen-
ter too.
255 255
6 Provision and Operation Stories with Scripting 6 Provision and Operation Stories with Scripting
Backend If your workload on the backend is particularly high, you won’t have a prob-
lem arising in SAP Analytics Cloud, and you need to take a closer look at
your data source. The best way to do this is to make several queries and try
to narrow down the problematic query. Once you’ve found a critical query,
look through it join by join and then make optimizations where necessary.
Application When you enter the story, you first have the option of limiting the upcom-
ing results set by using various filter criteria (see Figure 6.20). In addition to
the date of the session, you can filter the search by resource or user. Click
the Search button to display the sessions that match your search criteria.
You can now select the desired session from this results list.
In the view that appears, you’ll see detailed information about this session
(see Figure 6.21). You can then use this information to identify weaknesses
or problems in your story. Among other things, the start time of the story,
the five most time-consuming charts, and the models with the longest
backend time will be displayed.
The lower section of the overview provides you with detailed information
on the individual areas. You can take a closer look at the page load times,
256 256
6 Provision and Operation Stories with Scripting
6.3 Performance Monitoring
widgets, and general runtime. You can also filter these areas further (e.g., for
a specific action or page, for a specific widget).
The result of the client test is a benchmark score, which is calculated on the Benchmarking
basis of several benchmark measurements. Benchmark scores fall into limits
three categories:
257 257
6 Provision and Operation Stories with Scripting 6 Provision and Operation Stories with Scripting
To improve your benchmark score, you should pay attention to the CPU-
intensive applications and processes on your computer that have a nega-
tive impact on the performance of SAP Analytics Cloud.
Optimal Conditions
Don’t switch between browser tabs or minimize them during the test.
After the client test, you can run the network test, which returns three key
figures:
Network latency
This key figure is the result of a calculation based on your latency and
system bandwidth. The latency corresponds to the time that elapses
between the request and the response from the SAP Analytics Cloud
server.
Download bandwidth
This key figure indicates the amount of data transferred from the SAP
Analytics Cloud server to the client in megabits per second.
Upload bandwidth
This key figure corresponds to the amount of data transferred from the
client to the SAP Analytics Cloud server in megabits per second.
258 258
6 Provision and Operation Stories with Scripting
6.3 Performance Monitoring
You can use a dropdown list to jump to other pages where you can find
more detailed information.
Figure 6.24).
259 259
6 Provision and Operation Stories with Scripting 6 Provision and Operation Stories with Scripting
Here, you’ll find an overview of the active planning users and the models
they use, as well as an overview of the number of data actions in different
contexts, such as in the calendar or stories.
If you have entered the parameter in the URL or called up the story using
the button and the application has finished loading, you can call up the
popup using the key combination (Ctrl)+(Shift)+(A) or (Ctrl)+(Shift)+(Z).
260 260
6 Provision and Operation Stories with Scripting
6.3 Performance Monitoring
The popup with the loading times for the various scripts will then open (see
Figure 6.26). If you move the mouse cursor over the bar, the exact execu-
tion time will be displayed.
261 261
6 Provision and Operation Stories with Scripting 6 Provision and Operation Stories with Scripting
You are now in the developer tools of Google Chrome, where you can
search for your scripts, either via a search field or via the tree structure (see
Figure 6.28). To open the search field, press (Ctrl)+(P) on your keyboard,
and you can then search for the name of your widget or function. Name
suggestions are displayed during the search.
You can also search for your script using the tree structure on the left-hand
side (see Figure 6.29). You can find it under sandbox.worker.main, and
below it, you’ll see your story and its elements.
You can also use the debug mode in the development tools of SAP Analytics
Cloud. You start debug mode by adding the debug=true URL parameter to
your story, and the script will be automatically stopped as soon as you
reach a defined point. To include a breakpoint in your story, add the debug-
ger; instruction to your code.
262 262
6 Provision and Operation Stories with Scripting
6.3 Performance Monitoring
You can find another option for defining a breakpoint in the developer
tools. To do this, open the script to be stopped and select the line in the
developer tools where it should stop. To remove a breakpoint, click on it
again (see Figure 6.30).
263 263
6 Provision and Operation Stories with Scripting 6 Provision and Operation Stories with Scripting
You can make these settings either in the builder or via an API. In this way,
you can improve the performance of your story and avoid unnecessary
data updates. Three different modes are available for this purpose:
Always Refresh
This is the default setting in every story, and in this mode, the chart is
always updated.
264 264
6 Provision and Operation
6.4 Stories with Scripting
Best Practices for Performance
Inactive Widgets
Widgets that are located in inactive tabs, book pages, and popups are
treated as invisible.
formance of your story. As a result, all widgets visible at the start of the
story are loaded. In the next step, the invisible widgets are initialized in the
background.
The loadInvisibleWidgets URL parameter offers another option for calling
up a story in the corresponding mode. It overwrites the setting in the story.
The loadInvisibleWidgets URL parameter can contain two different values:
loadInvisibleWidgets=onInitialization
This value forces the standard mode and loads all widgets at the begin-
ning.
loadInvisibleWidgets=inBackground
This value activates the mode to load the invisible widgets in the back-
ground.
265 265
6 Provision and Operation Stories with Scripting 6 Provision and Operation Stories with Scripting
The widget is now initialized with all other visible widgets at startup, even
if it’s in the background. You can find the setting for this in the designer in
the Format area.
6.5 Summary
In this chapter, you’ve learned different ways to provide your stories and
how to interact with a web application or embed stories into a web applica-
tion. The most important parts of this chapter were the sections where you
learned how to detect performance pain points in your stories and scripts
and follow best practices to avoid performance issues. In the next and final
chapter, we’ll give you our outlook on the SAP Analytics Cloud roadmap.
266 266
Josef Hampp, Jan Lang
Application
Development with
SAP Analytics Cloud
■ Use scripting to develop custom
analytical applications in SAP
Analytics Cloud
■ Create complex dashboards and
applications tailored to your business
■ Extend your applications with
standard widgets, custom widgets,
and APIs
www.sap-press.com/5944
Josef Hampp works as a customer advisor for SAP Business Technology Plat-
form at SAP SE, with a specific focus on SAP’s data and analytics solutions. Jan
Lang is a leading expert for data management and reporting at FC Bayern
Munich, where he works with BI technologies from SAP.