Skip to Content

     This post focuses on how you can bypass the HANA logon or make an anonymous call for accessing an XSJS service. I would also share the challenge I faced when a XS app was wrapped as an Android app. How to create an Android PhoneGap plugin for UI5 Mobile

     We might come across a situation where we need to bypass the default Form/Basic authentication. In my case, after wrapping the XS App into an .apk I couldn’t navigate to any of my XSJS services unless I logged in with the usual HANA logon authentication. SQLCC helps by enabling us to configure the connection to the database, we can also use specific config for your individual SQL Connections. Below are the steps to achieve this.

Roles you would require:

  1. sap.hana.xs.admin.roles::SQLCCViewer
  2. sap.hana.xs.admin.roles::SQLCCAdministrator


The first step would be to create an .xssqlcc file in your XS project or using New -> Other -> Application Development -> SQL Configuration File

{

“description” : “Test SQL connection”

}

Activating this would create an entry in “_SYS_XS”.”SQL_CONNECTIONS”. Note that the USERNAME needs to be updated.

Post_2.jpg

  •      Update the USERNAME using the below URL

               http://hostname:port/sap/hana/xs/sqlcc

Post_3.jpg


                   After Update :

Post_4.jpg

  •      You can manage the security for your package from the below link.

              http://hostname:port/sap/hana/xs/admin/

Once the XSSQLCC is created, all you need to do is to use it in your application. We can do this in two ways :


          1) Set the parameter in my .xsaccess file

{

   “anonymous_connection”: “SQLCC::testsqlcc”,

   “exposed” : true,

   “authentication” : null

}

          2) Passing the “SQLCC::testsqlcc” as parameter in my $.db.getConnection();

          Note : SQLCC file and the XSJS service SHOULD be in the same package, so that service can access the SQL Connection Configuration file

          Below is a simple snippet of a XS app that calls the SQLCC .

//Open a DB connection

  var conn = $.db.getConnection(“SQLCC::testsqlcc”);

  var oResult = [];

  var sql = “SELECT CUST_ID,CUST_NAME FROM \”TEST\”.\”CUSTOMER\””;

  var pstmt = conn.prepareStatement(sql);

  var rs = pstmt.executeQuery();

  while(rs.next()){

  oResult.push({

  “ID” : rs.getString(1),

  “Name” : rs.getString(1),

  });

  }

  rs.close();

  conn.close();

  $.response.setBody(JSON.stringify(oResult));

Result:

Post_1.jpg

And now I have a service which does not throw a Basic pop up/Form logon. This helped us in navigating to the required service from the XS app which was wrapped as Android App.

Another authentication which you could explore would be OAuth !


Hope this post was helpful !


Avinash Raju

SAP HANA Consultant

www.exa-ag.com

To report this post you need to login first.

11 Comments

You must be Logged on to comment or reply to a post.

  1. Anup Singh

    Good information Avinash,

    I’m getting below error when trying to call procedure from xsjs file:

    “dberror(CallableStatement.execute): 2048 – column store error: search table error: [2620] executor: plan operation failed;Can not insert data from temp table into Result_Table”

    I have verified i/p & o/p data types and the same code works fine on studio SQL editor , but facing issue only executing the same from xsjs.

    Please let me know any other suggestions ..

    Thanks & Regards,

    Anup Singh

    (0) 
      1. Diana Fernanda Vazquez Romo

        Hey! So I am trying to do this and can’t seem to find where one would set up the username. I have already granted the RuntimeConfAdministrator role.

         

        I just see a view of the sqlcc object where it says Username is ‘Not Set’. What am I missing?

        (0) 
    1. L L

      You can, just log on to the web based development workbench of your hana mdc created in hcp trial, and in the Editor, follow the path in the directory structure starting from root: /sap/hana/xs/admin/ and you’ll find an index.html there which you have to start. But first assign in the Security tool all *xs.admin* roles to e.g. your SYSTEM user.

      (0) 
      1. Diana Fernanda Vazquez Romo

        Hey! As I described above, (response to Xana Rasquin’s comment) I cant seem to find how to setup username. I have granted to appropriate privileges and everything but I simply don’t see a button that would allow me to setup the username.

        (0) 
  2. Sivaiah Papudesi

    Nice to see this blog, and I also would like to know one more point here – if we implement this then when we run the service will it asks HANA access credentials OR is it suffice that if we give the USERNAME and PASSWORD what we created here?

    Thanks,

    Siva

    (0) 
  3. Nitin Singh

    Hi Avinash,

     

    How can I add job scheduler job role using sqlcc? is it possible? a user will have login credentials but won’t have job schedule role.

    Thanks

    Nitin

    (0) 

Leave a Reply