Create a XSJS application consume calculation view and sent it to Https in HANA...
source link: https://blogs.sap.com/2023/01/06/create-a-xsjs-application-consume-calculation-view-and-sent-it-to-https-in-hana-xsa/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
Create a XSJS application consume calculation view and sent it to Https in HANA XSA
In this section I will discuss about the create a XSJS application consume calculation view and sent it to Http response to SAPUI5 in SAP HANA XSA using WEB IDE.
Architecture :
Steps :
1. Create a Calculation view using required tables in the HDI container. For our case we created a CV CV_EMPLOYEE from table employee. The detail is given below –
2. Create a Node.js application and inside lib folder create a employee.xsjs application.
3. Create the employee.xsjs inside lib folder and implement the below code to access the data.
var employee = [];
var stmnt = null;
var rs = null;
var conn = $.db.getConnection();
var stmnt = conn.prepareStatement( "select * from "PLB_DB.OFFICE"::"CV_EMPLOYEE" );
var rs = stmnt.executeQuery();
if (!rs.next()) {
$.response.setBody( "Unable to get result" );
$.response.status = $.net.http.INTERNAL_SERVER_ERROR;
} else {
emp = {};
emp.emp_id = resultSet.getString(1);
emp.emp_name = resultSet.getString(2);
emp.emp_mail_id = resultSet.getString(3);
emp.address = resultSet.getString(4);
employee.push(emp);
}
rs.close();
pstmt.close();
conn.close();
try{
$.response.contentType = "application/json";
$.response.setBody(JSON.stringify(employee));
}
catch(err){
$.response.contentType = "text/plain";
$.response.setBody("Got error : [" + err.message + "]");
$.response.returnCode = 400;
}
4. Build the DB Module first. Then build the Node.js module . Run as Node.js application and you can see the calculation view has been expose in json format in browser.
Hope this will help.
Recommend
-
4
java-version.com: What's new in Java 16? 15? Keep up to date! Android: consume a REST / HTTPs service using JSON and Threads...
-
3
Jan Zwickel December 20, 2021 2 minute read
-
5
Sreekanth Surampally April 24, 2022 1 minute read
-
3
Ashish Jain May 29, 2022 5 minute read ...
-
4
Within the time frame of 2022 QRC2, several new calculation view features have been released in SAP HANA Cloud that can be used with SAP Business Application Studio. Some of these features are highlighted below. Calculation View Snapshots
-
5
Know someone who can answer? Share a link to this Before answeringYou should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more i...
-
1
Chau Nguyen Phuc December 3, 2022 2 minute read...
-
0
Chau Nguyen Phuc December 3, 2022 1 minute read...
-
1
PALLAB HALDAR January 2, 2023 2 minute read
-
1
PALLAB HALDAR November 23, 2020 5 minute read...
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK