Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

HANA XS

Hello all, I am new to HANA.

I am currently using hana trial version.

I have created XS application, and it was execeuted successfully, by creating hello.xsjs, xsaccess, xsapp files.

I have created a table called TEST in my inbuilt schema, and also created xsjs file in the following way,

============================================

function getDataFromTable(){

  var id = $.request.parameters.get("id"); 

  if (id === null) { 

     $.response.setContentType("text/plain"); 

     $.response.addBody("id is null!"); 

  } 

  var val1 = $.request.parameters.get("val1"); 

  if (val1 === null) { 

     $.response.setContentType("text/plain"); 

     $.response.addBody("val1 is null!"); 

  } 

  var output = {}; 

  output.data = []; 

  var conn = $.db.getConnection();

  conn.prepareStatement("SET SCHEMA \"xxxxxxxxx\"").execute(); 

  var st = conn.prepareStatement("INSERT INTO \"xxxxxxxtrial.p1234567.hello","TEST\"  values(1,K)");

  st.setString(1,id); 

  st.setString(2,val1); 

  st.executeQuery();

  st.execute(); 

  conn.commit(); 

  var record = []; 

  record.push(id); 

  record.push(val1); 

  output.data.push(record); 

  conn.close(); 

  $.response.setContentType("text/json"); 

  $.response.addBody(JSON.stringify(output)); }

along with this , also created xsaccess, xsprivileges, xsapp,  TEST.hdbtable,model_access.hbd role files .

==========================================================================================================

model_access.hbdrole ---------- (role xxxxxxxxxtrial.p1234567.hello::model_access {

     application privilege: xxxxxxxtrial.p1234567.hello::Basic;

}

But when I am trying to run the xsjs file, I am unable to see the table and inserted values , it is showing me blank page.

Could you please help me.

Tags:
Former Member
replied

Where is the call of function "getDataFromTable" in your Hello.xsjs? Do you set in your new version any response after your insert statement? The line with "st.executeQuery()" can be removed because it is not necessary for the insert.

Maybe you can set at the end a response body like a string "ok" to check if anything is returned and your script is at least executed.

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question