on 11-25-2012 6:04 PM
Hi Gurus,
I researched a lot about the connectivity options between a mobile app and HANA, but all I get is about retrieving data from HANA and sending it back to a mobile device/app.
Is there a way of sending data to HANA from a Mobile App ?
Currently, I am aware of one way but I do not see any documents of implementing it:
--> Doing a Http post in an android api and consuming that in XS engine and then passing it to HANA.
If anybody could provide any documents on the above way, I would be more than happy.
Also, do you see any better ways of achieving this ?
Best Regards,
Chandan
HI
can any one tell how we can pass value from .js file to .xsjs .??
I need to set data according to the Id which i will be getting on clicked in xs file ..
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Chandan,
Documentation around XS is a little limited at the moment, and more should come out with the release of SPS05. With regards to your question, it is possible to call a Stored Procedure from XS and pass values into the Stored Procedure. You could create a Stored Procedure that would then insert, or update values in SAP HANA. Let me know if you need more details and I'll check with one of my colleagues who have done this.
Regards,
Gary Elliott
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Chandran,
The stored procedure is called through a JS Server Script within XS. I'm not sure how this is called from an App, as I'm a HANA guy, not an App guy. I suggest that you hold out for SPS05 as I'm led to believe that there will be documentation on XS released as part of this release.
Cheers,
Gary
Hi,
XSEngine doee not have this capability now. You can not insert data uaing it. You can use miidlewares for example SUP. Or you can code for it. Using Jdbc you can connect HANA.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
As I said before it is not official yet. I only read it from TechEd Session. And may be this might be not supported on your server. And I think right approache is using a middleware for this. Check SAP NW Gateway. You can read data from HANA too. But you can write custom code for inserting data.
Not really.
I was talking about creating a .xsjs file in HANA (it stands for server side JavaScript) with something like this:
insert.xsjs
var id = $.request.getParameter("id");
if (id === null) {
$.response.setContentType("text/plain");
$.response.addBody("id is null!");
}
var val1 = $.request.getParameter("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 \"TEST\"").execute();
conn.prepareStatement("INSERT INTO \"TABLE1\" values('" + id + "', '" + val1 + "')").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));
And then, in order to call it, just do a HTTP GET to the URL pointing to your .xsjs file, passing the URL parameters.
In order to test it, you can just access the URL in the browser directly.
If everything goes ok, you should see the inserted record sent back as the response to the HTTP GET command (in JSON format).
Anything else should be interpreted as an error.
For example, calling http://<host>:<port>/test/logic/insert.xsjs?id=1&val1=10.5 in your browser, will get you this record being inserted in the TABLE1 table:
And this is the output you should see in your browser:
Best regards,
Henrique.
PS: in my case, TABLE1 had "ID" as a primary key. Hence, if I just call the same URL again, it will try to insert another record with the same key, and hence it will fail. But since I didn't handle the exception in my code, it will throw a HTTP 500 error. If you want to avoid that, you'll need to do some exception handling in your .xsjs file.
PS2: in order to properly test your .xsjs file, you'll need to define a XS application for the package that contains it.
Just make sure to create a .xsapp file like below in the root folder of that package in order to tell HANA that this is an existing XS Application, or else trying to call that URL above will just throw a HTTP 404 error.
test.xsapp
{
"auth_required": true
}
User | Count |
---|---|
84 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.