Skip to Content
Author's profile photo Former Member

Alternate SAP HANA xsjs Debugging

Use case:

Invoke xsjs application from html.

Most people may know about debugging an xsjs application using the hdbstudio.

Supposing, for some reason, the debug configuration is not able to connect to the correct session, there is an alternate way to debug the application.

HTML snippet – MyHTML.html:




          function onBody() {

          var aUrl = ‘../services/MyService.xsjs’;


          url: aUrl,

          method: ‘GET’,

          dataType: ‘json’,

          success: this.onCompleteBody,

          error: this.onBodyError



          function onBodyError(myTxt){



          function onCompleteBody(myTxt){

              oModel.setData({ bData : myTxt });





<body  onLoad=onBody()>




================= End of MyHTML.html ================



var errtxt=”;     // Empty string



errtxt += ‘1:’;

SQL statement 1

errtxt += ‘2:’;

SQL statement 2;



errtxt += ‘n:’;

SQL statement n;

$.response.contentType = ‘application/json’;
$.response.status = $.net.http.OK; 


  catch (err)


$.response.contentType = ‘text/plain’;
errtxt += ‘:Error : ‘ + err;
$.response.setBody(errtxt );
$.response.status = $.net.http.INTERNAL_SERVER_ERROR; 


———  END of MyService.xsjs —————


Using chrome or firefox run the MyHTML.html in developer mode and debug it.

Set break point at

          function onBodyError(myTxt){

           >   alert(myTxt.statusText);   // break point at alert


If there is any error you can view the object myTxt contents and the myTxt.responseText will show the errtxt set in MyService.xsjs.

This will show on which SQL statement, the xsjs failed along with error code.

Hope this helps your debugging efforts.

Assigned Tags

      1 Comment
      You must be Logged on to comment or reply to a post.
      Author's profile photo Former Member
      Former Member

      Hi Sreeram NK

      Your solution is very creative.Good Going 😎