Introduction
This document will brief us on how we can develop a native XS Application using SAP HANA cloud platform. We will also see how we can connect SAP Lumira Desktop with SAP HANA cloud platform and develop visualization on the data put into SAP HANA Cloud.
In this document, we would be going through following steps to create visualizations:-
Steps:
- Connect to SAP HANA Cloud Platform from Eclipse IDE.
- XS Project is created and it should be stored in SAP HANA Repository.
- Create a Calculation View on the data of SAP HANA Cloud Platform using SAP HANA Modeler
- Create a DB Tunnel and Connect SAP Lumira Desktop to SAP HANA Cloud platform using the DB tunnel credentials.
- Once SAP Lumira is connected to SAP HANA Cloud, Analyze the data of HANA Cloud Platform by making visualizations.
Firstly, we need to install Eclipse IDE version Mars or Luna. We need to install SAP HANA tools for Eclipse.
Procedure to install SAP HANA Tools for Eclipse.
1. Open Eclipse IDE. From the menu bar, select Help->Install New Software.
2. Select the whole group SAP HANA Tools.
3. Click Next and Finish the wizard.
Create a SAP HANA instance
1. First we have to register and login to SAP HANA Cloud Cockpit using the given link.
https://account.hanatrial.ondemand.com/cockpit
2. We need to select “Database and Schemas” to create a New trial instanceof SAP HANA database.
3. Give the Schema ID name and select Database System and save the entries.
Connect to SAP HANA Cloud DB from Eclipse IDE
- Open SAP HANA Development Perspective and choose Add Cloud System.
- We need to enter our SAP HANA Cloud trail account details.
- Select the same Trial Instance of SAP HANA DB.
Create an XS Project in Eclipse IDE
1. Open the Project Explorer and select File->New Project. Select XS Project.
2. Select “Share Project in SAP Repository” checkbox.
3. Then, create Repository Workspace that will also hold our XS project.
Reading CSV File in SAP HANA Cloud Platform
1. In SAP HANA Cloud Platform Cockpit Select the Database and Schema and select the schema id created and go to Development tools: SAP HANA Web-based Development Workbench.
2. In Project Explorer, Create a new package and select File->New->File. We need to enter the file name as .xsapp and choose Finish.
3. Create one more file with the name .xsaccess. . Write the following code in the file and save.
{
exposed” : true,
“default_file” : “hello.xsjs”
}
4. Create hello.xsjs file and write the following code.
$response.contentType = "text/html";
var output = "Hello, " + $.session.getUsername() + " <br><br>";
var conn = $.db.getConnection();
var pstmt = conn.prepareStatement( "SELECT CURRENT_USER FROM DUMMY" );
var rs = pstmt.executeQuery();
if (!rs.next()) {
$.response.setBody( "Failed to retrieve data" );
$.response.status = $.net.http.INTERNAL_SERVER_ERROR;
}
else {
output = output + "This is the response from my SQL. The current user is: " + rs.getString(1);
}
rs.close();
pstmt.close();
conn.close();
$.response.setBody(output);
- 5. Right Click on Package and go to File->Import. Import the CSV file. e.g. bus.csv
- 6. Create a new file with the name bus.hdbti and write the following code in it
import = [
{
table = "s0009779955trial.hana::mymodel.bus";
schema = "_SYS_BIC";
file = "s0009779955trial.hana:bus.csv";
header = false;
}];
- 7. Create one more file with the name mymodel.hdbdd and write the following code in it.
namespace s0009779955trial.hana;
@Schema: '_SYS_BIC'
context mymodel {
type SString: String(60);
@Catalog.tableType: #COLUMN
@nokey Entity busfinal {
busno: Integer;
source: SString;
destination: SString;
arrival: SString;
departure: SString;
distance : Integer;
route : SString;
Seatno : Integer ;
};
}
Column name in the code above should be same as used in CSV file.
8.We need to activate the files by selected Team->Activate.
Note: Use Quick fix to change the encoding of individual files to UTF-8.
Create Calculation View
1. In the Repository Package, a calculation view of type “Graphical” is created.
2. In the Scenario Editor, add a Join Node.
3. In the Join Node, select and drop the tables from schema you want to join.
4. Select the columns that you want to show in calculation view and choose “Add to Output”.
5. In the Scenario Editor, we need to link the join node with the aggregation node.
6. Select the aggregation node and add all the columns to output.
7. Semantics node should be selected and the enable analytic privilege checkbox in the Details pane should be deselected
8. View should be Saved and Activated.
The user needs to be granted select privileges. This is done by calling a procedure through the following in SQL Console.
CALL "HCP"."HCP_GRANT_SELECT_ON_ACTIVATED_OBJECTS"
Catalog Folder is refreshed and generated calculation view can be seen in _SYS_BIC schema.
We can connect “SAP Lumira Desktop” with SAP HANA Cloud Platform by creating a DB tunnel.
We need to run the following command at command prompt.
neo open-db-tunnel -a <account_name> -h <landscape_host> -u <user> -i <schema_ID>
<landscape_host> = hanatrial.ondemand.com
This cmd will give us the password to connect to SAP HANA Cloud Platform.
Once SAP lumira is started, we can connect to SAP HANA Cloud Platform using the credentials of DB tunnel and see the calculation view created in SAP HANA Cloud.
We can make visualizations in SAP Lumira by making use of SAP HANA cloud platform data and analyze the data accordingly.
Hope you like reading my blog.
Please do not forget to provide your valuable feedback and responses.
Thanks & Regards,
Saurabh Raheja