You are on page 1of 6

2/8/24, 8:36 PM Commenting Functionality in SAP Analytics Cloud(SAC)!

(2/2)

Tharun Karnam May 24, 2021 3 min read

Custom Built Commenting Functionality in SAP Analytics


Cloud(SAC)! (2/2)
Updated: Dec 29, 2023

In Continuation, with the blog post published earlier


https://www.techgenius.in/post/comments-in-sap-analytics-cloud
Let us discuss the technical details about the solution implementation and a demo here in the following blog.
So, get ready to dive in through the details.

As shown in the above picture, we will use SAC Analytical Application, as it has the flexibility to custom code.

Let's consider the scenario where we are doing Sales Analysis of different sales managers in the SAC Analytical
Application. We need commenting functionality during the review meeting for the Head of Sales, to add his
comments on the different sales managers.
The first object to be created is the HANA table, where we will be storing/saving the comments which are added
from the SAC Analytical Application, the HANA table will have fields like below.

https://www.techgenius.in/post/commenting-functionality-in-sap-analytics-cloud-sac-part2 1/6
2/8/24, 8:36 PM Commenting Functionality in SAP Analytics Cloud(SAC)! (2/2)

COMMENT_ID : The id of the comments, is the primary key for the table.
STORY_VALUE : The filter value of the context, for instance, in this demo, we are analyzing the sales manager, so
Sales Manager ID can be passed as filter value to this column
COMMENT: The textual comment that is to be saved.

Once we have the table ready, we create a HANA calculation view, on top of the HANA comments table. This
HANA view is used to retrieve the comments stored in the table in the SAC Application using the HANA live
connection.

The next step is to create a SAC Analytical model using the calculation view.
Later, we will come to the interesting part, that is to provide an interface to the user to input the comments, for this
purpose ,we will use the UI5 Web application.
The UI5 Web application can be custom designed to suit the user requirements, in our case. we only need to input
one comment at a time.

https://www.techgenius.in/post/commenting-functionality-in-sap-analytics-cloud-sac-part2 2/6
2/8/24, 8:36 PM Commenting Functionality in SAP Analytics Cloud(SAC)! (2/2)

We have used XSJS to do the server-side scripting, which will capture the comment entered and saves it into the
table.
We can add different operations like Create, Update, Save and History to do the creation of comments, Updating,
saving of modified comments and Auditing of the comments
respectively in the UI5 Web Application.
In case, if you need to comment on multiple fields at a time, you can add more UI elements to the web application.
Once we have these objects ready, we will move to the SAC Analytical Application to create the front end elements
like Graphs and Tables in the dashboard.

For the SAC Part, We will use the SAP demo model which is the "BestRunJuice_SampleModel".
First, let us create a sample chart showing the Gross Margin and Quantity Sold, by each Sales Manager for different
products.

https://www.techgenius.in/post/commenting-functionality-in-sap-analytics-cloud-sac-part2 3/6
2/8/24, 8:36 PM Commenting Functionality in SAP Analytics Cloud(SAC)! (2/2)

For this, we add the Table widget in SAC using the SAC Analytical Model, which we just created above.

We will select only the comment column for display in the designer tab of the analytical application.

In addition to the table widget, we will add a text box "Add Comments" to make it intuitive to the user, that he can
add the comments here.
Also, we need a button, for simplicity, we will use the "+" symbol which easily says that the comments can be
added here.

Once the user clicks on the "+"(Add comment) button, it will open a popup in the SAC Analytical Application. In the
pop up, we will embed the UI5 Web Application which we created earlier.

https://www.techgenius.in/post/commenting-functionality-in-sap-analytics-cloud-sac-part2 4/6
2/8/24, 8:36 PM Commenting Functionality in SAP Analytics Cloud(SAC)! (2/2)

Now, to make the selection easier, we will create a drop-down that has values to filter the sales managers. Here we
have hard-coded the values, but we can use variables to bind to the drop-down to display the selections.

Now we add some code to the Add Comments(+) button to capture the drop-down filter values.

CommentsEditor_Popup.open();
var final Url = web_app_url + Dropdown_1.getSelectedKey();
WebPage_1.setAddress(final_Url);

This code will open the popup window and then we capture the value selected in the drop-down and add it to the
URL as a parameter.
Then we set the address for the webpage which is the UI5 application.
The drop-down code onSelect() will look something like below:

https://www.techgenius.in/post/commenting-functionality-in-sap-analytics-cloud-sac-part2 5/6
2/8/24, 8:36 PM Commenting Functionality in SAP Analytics Cloud(SAC)! (2/2)

var filter = Dropdown_1.getSelectedKey();


Chart_1.getDatasourec().setDimensionFilter("Sales_Manager",filter);
Comments_Table.getDatasource().setDimensionFilter("STORY_VALUE",filter);

whenever there is a value selected in the drop-down, the chart and comments table will have the corresponding
value filtered based on the context.

Now, we have all the elements in place!! Let's run the demo to see the solution in action!!

0:00 / 1:36

https://www.techgenius.in/post/commenting-functionality-in-sap-analytics-cloud-sac-part2 6/6

You might also like