Skip to Content
Technical Articles
Author's profile photo PALLAB HALDAR

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 with XSJS support and inside lib folder create a employee.xsjs application.


4. Add this DB module db_plb to node.js module(with XSJS support) as a required module.

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 "DB_PLB.OFFICE"::"CV_EMPLOYEE" );
var rs = stmnt.executeQuery();

if (! {
  $.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);

		$.response.contentType = "application/json";
		$.response.contentType = "text/plain";
		$.response.setBody("Got error : [" + err.message + "]");
		$.response.returnCode = 400;


4. Build the DB Module first. . Run as Node.js application and you can see the calculation view has been expose in son format in browser.




Note : at this stage we do not implement security. We will create in the Web module and push it to the XSJS in the next blog.



Assigned Tags

      Be the first to leave a comment
      You must be Logged on to comment or reply to a post.