Professional Documents
Culture Documents
Application Services (sometimes referred to unofficially as XS or XS Engine). The core concept of SAP HANA
Extended Application Services is to embed a full featured application server, web server, and development
environment within the SAP HANA appliance itself. However this isn't just another piece of software installed
on the same hardware as SAP HANA; instead SAP has decided to truly integrate this new application services
functionality directly into the deepest parts of the SAP HANA database itself, giving it an opportunity for
performance and access to SAP HANA differentiating features that no other application server has.
Before SAP HANA SP5 if you wanted to build a lightweight web page or REST Service which
consumes SAP HANA data or logic, you would need another application server in your system
landscape. For example, you might use SAP NetWeaver ABAP or SAP NetWeaver Java to connect
to your SAP HANA system via a network connection and use ADBC (ABAP Database Connectivity)
or JDBC (Java Database Connectivity) to pass SQL Statements to SAP HANA. Because of
SAP HANAs openness, you might also use Dot Net or any number of other environments or
languages which support ODBC (Open Database Connectivity) as well. These scenarios are all still
perfectly valid. In particular when you are extending an existing application with new SAP HANA
functionality, these approaches are very appealing because you easily and with little disruption
integrate this SAP HANA functionality into your current architecture.
However when you are building a new application from scratch which is SAP HANA specific, it makes sense to
consider the option of the SAP HANA Extended Application Services. With SAP HANA Extended Application
Services you can build and deploy your application completely self-contained within SAP HANA; providing an
opportunity for a lower cost of development and ownership as well as performance advantages because of the
closeness of the application and control flow logic to the database.
Applications designed specifically to leverage the power of SAP HANA, often are built in such
a way to push as much of the logic down into the database as possible. It makes sense to
place all of your data intensive logic into SQL, SQLScript Procedures, and SAP HANA Views, as
these techniques will leverage SAP HANAs in-memory, columnar table optimizations as well
as massively parallel processing. For the end-user experience, we are increasingly targeting
HTML5 and mobile based applications where the complete UI logic is executed on the client
side. Therefore we need an application server in the middle that is significantly smaller than the
traditional application server. This application server only needs to provide some basic validation
logic and service enablement. With the reduced scope of the application server, it further lends
credit to the approach of a lightweight embedded approach like that of the SAP HANA Extended
Application Services.
development tools are integrated into SAP HANA Studio, they are not installed automatically. For installation
instructions, please see section 10.1 of the SAP HANA Developers Guide.
OData Services
There are two main parts of the SAP HANA Extended Application Services programming model. The first is
the ability to generate OData REST services from any existing SAP HANA Table or View. The process is
quite simple and easy. From within an SAP HANA Project, create a file with the extension xsodata. Within this
service definition document, the developer needs only to supply the name of the source table/view, an entity
name, and, if using an SAP HANA View, the entity key fields.
For example, if you want to generate an OData service for an SAP HANA table named teched.epm.db/
businessPartner in the Schema TECHEDEPM, this would be the XSODATA definition file you would create:
"TECHEDEPM"."teched.epm.db/businessPartner" as "BUYER"; }
of 3 party tools based upon JavaScript, like Sencha, Sencha Touch, JQuery, JQuery Mobile, and PhoneGap,
just to name a few; SAP delivers the UI Development Toolkit for HTML5 (SAPUI5) standard in SAP HANA
Extended Application Services. A particularly strong feature of SAPUI5 is the integration of OData service
consumption not just at a library level but also with special features within the UI elements for binding to OData
services.
For example, within SAPUI5, you can declare an OData model object and connect this model object to the URL
of the XSODATA service. Next, create a Table UI element and connect it to this model object. Finally you call
bindRows of the Table UI element object and supply the OData entity name you want to use as the source of
the table.
This creates an UI Element which has built-in events, such as sort, filter, and paging, which automatically call
the corresponding OData Service to fulfill the event. No additional client side or server side programming is
necessary to handle such events.
XSJS). Core APIs of SAP HANA Extended Application Services are, therefore, exposed as JavaScript
functions; providing easy access to the HTTP Request and Response object as well database access to
execute SQL or call SQLScript Procedures.
In this simple example, we can take two numbers as URL Request Parameters and multiply them together and
then return the results as text in the Response Body. This is an intentionally basic example so that you can
focus on the API usage.
Closing
This blog hopefully has served to give you a small introduction to many of the new concepts and possibilities
with SAP HANA SP5 and SAP HANA Extended Application Services.
Over the coming weeks, we will be posting additional blogs with more advanced examples and techniques as
well how to integrate SAP HANA Extended Application Services content into additional environments. Likewise
there is a substantial Developers Guide which expands on many of the concepts introduced here.
It is also important to note that while SAP HANA Extended Application Services ships as
productive software (meaning customers can go live in production with it) in SAP HANA SP5; it is
a controlled release initially, with a special Project Solution program in place around this new
functionality. Please refer to Service Note 1779803, for additional details on the current status
of the Project Solution. This Project Solution approach is designed to provide the highest levels
of support possible to initial customers and partners who choose to develop using SAP HANA
Extended Application Services. It also provides a channel for feedback to Product Management
and development so that we take suggestions and ideas and quickly integrate them into future
revisions of SAP HANA and SAP HANA Extended Application Services.
103803 Views Tags: sapmentor, hana, developer, code, database, in_memory, sap_mentor, hana_devcenter,
sap_hana, sapui5, hana_studio, xs, hde, xsjs, xsodata
Glen Ooi
Dec 23, 2014 3:45 PM
Hi Thomas,
In need of your expert advice.
I have a situation where I am using BO Dashboards to create my Dashboard which is consuming the data from
HANA.
I have a requirement to allow the user to comment in the dashboard and it will write back to the HANA DB and
also display the comments in the Dashboard.
In order for the BO Dashboard to write back to HANA DB is via web services.
Is there any way i can create a WSDL URL and consume the XSJS or ODATA services in HANA?
Muhammad Sadiq
Dec 10, 2014 1:40 PM
I need your help in writing an API(XSJS service) which will take JSON format data and inserted into HANA
database.
Tarasankar Banerjee in response to Thomas Jung on page 14
Nov 5, 2014 8:52 AM
Thanks Thomas. Could you give an example of how to redirect.
I'm facing a strange issue while trying to import weather data from several cities together. The issue appears to
be connected with the content of the response object.
Following is the code of the Weather.xsjs file:
try
{
var cmd = $.request.parameters.get("cmd");
var body;
var response;
var obj;
var propertyName;
$.response.contentType = "text/plain";
if(response.body)
{
body = response.body.asString();
obj = JSON.parse(body);
}
/*
body = cmd + "\n \n" + response.status + "\n \n" + response.contentType
+ "\n \n" + response.body + "\n \n" + obj.getOwnPropertyNames();
*/
$.response.setBody(body);
$.response.status = $.net.http.OK;
}
catch(e)
{
$.response.contentType = "text/plain";
$.response.setBody(e.message);
$.response.status = $.net.http.INTERNAL_SERVER_ERROR;
}
Following is the weather.xshttpdest:
host = "api.openweathermap.org";
port = 80;
description = "my weather checker";
useSSL = false;
pathPrefix = "/data/2.5";
authType = none;
useProxy = true;
proxyHost = "<proxy_details>";
proxyPort = "<proxy_port";
timeout = 0;
On accessing http://<hostname>:8000/root/work/Tara02/XSTest01/XSHttpTest01/Weather.xsjs?
&cmd=import, I am receiving the error message: Body.asString : unsupported charset specified in
Content-Type header ("utf8") .
If the body = response.body.asString(); statement is commented out, I receive the error message
JSON.parse: unexpected character because the response.body.asString() itself could not work correctly.
However the URL http://api.openweathermap.org/data/2.5/group?
id=1275004,1264527,1277333,1273294,1275339 returns data correctly.
Could you please advise regarding this issue. Thanks for your help.
Regards
Tarasankar
Thomas Jung in response to Tarasankar Banerjee on page 14
Nov 4, 2014 3:19 PM
>Is it possible to read files using XS? For example some configuration file kept in the server?
No there is no API to read from the file system of the underlying operating system. You can read the HANA
configuration ini files however because they are exposed via SQL.
>Is it possible to call a html file from the xsjs file? Something likerequest.getRequestDispatcher().forward() from
JAVA servlets?
In the body of the response you send back to the client your could issue a redirect.
Tarasankar Banerjee in response to Tarasankar Banerjee on page 15
Nov 4, 2014 10:34 AM
Hi Thomas,
Finally got my application running.. It is now fetching weather data from external sites..
..
Thanks.
Regards
Tarasankar
Robert Weber
Nov 3, 2014 11:36 AM
If someone is having difficulties with the alert "log full" on the xsengine:
you can do the same trick as for the statisticserver in oder to reset the log area, see details in OSS Notes
2019148 and 1950221.
The commands are then:
select VOLUME_ID from m_volumes where service_name = 'xsengine';
ALTER SYSTEM ALTER CONFIGURATION ('daemon.ini', 'host', '<hostname>') UNSET
('xsengine','instances') WITH RECONFIGURE;
However it did not bring any data. The content of the response object indicated that there was Proxy
authentication issue.
When I tried to check the Destination in the XS Admin Console, surprisingly none of the fields are populated
and everything (except the 'Trust Store' drop down) is disabled. All these fields are supposed to be populated
as indicated in the Modeling Guide.
The same scenario was present for the Http Destination I prepared earlier. There are couple of internal errors
at the bottom. On clicking them the following list is displayed.
1. Internal Error: dbError(Connection.prepareStatement): 258 - insufficient privilege: Not authorized at
ptime/query/checker/query_check.cc:2418
2. No valid SAP Crypto configuration.
It appears from various blogs that the second error (No valid SAP Crypto configuration) is related to SSL
configuration in HANA. I would contact the HANA Administrator to look into this issue. Of course it would be
great if you could provide some insight.
However I have no clue regarding the first error. Request your help and cooperation in this regard.
The initial issue of not finding the HttpDestination which I created still persists.
Thanks for all your help.
Regards
Tarasankar
Thomas Jung in response to Tarasankar Banerjee on page 18
Oct 31, 2014 3:42 PM
First of all, you would never use the workspace name. It isn't ever part of anything. It is only the package
structure that counts. The first item in your list is the only one with the correct package. Off hand it looks right to
me. You are supposed to supply the full package path. Have you configured this HTTP Destination in the XS
Admin tool yet?
Tarasankar Banerjee in response to Thomas Jung on page 18
Oct 31, 2014 3:26 PM
Updated it. Thanks.
Regards
Tarasankar
Thomas Jung in response to Tarasankar Banerjee on page 18
Oct 31, 2014 3:13 PM
Your comment got cut off. We never really get to see what your problem is.
Tarasankar Banerjee in response to Thomas Jung on page 21
Oct 31, 2014 2:56 PM
Thanks Thomas.
I am facing as issue while trying to use an HTTP Destination. I understand that the .xshttpdest and .xsjs file
need to in the same folder. Following is the structure of my test project.
As you can see the HTTP Destination and the XSJS files are in the same folder 'services'. The workspace
name is 'XS_Workspace' and the package structure is as follows:
Just watched the video you shared above. Thanks a lot for it. It is really informative and helpful.
Regards
Tarasankar
Tarasankar Banerjee in response to Tarasankar Banerjee on page 22
Oct 30, 2014 3:46 AM
Got answer for the second point. SAP HANA XS Administration Tool is the place to configure Proxy settings.
Regards
Tarasankar
Tarasankar Banerjee in response to Tarasankar Banerjee on page 22
Oct 29, 2014 3:14 PM
Dear Thomas,
another question is that does the proxy settings in the HttpDestination refer to the OS user of the HANA
server? We specify 'useProxy' as 'true' and 'authType' as 'basic' in the HttpDestination, but not maintain any
user credentials. So when the program runs in server, would it automatically consider the OS user credentials?
Thanks.
Regards
Tarasankar
Tarasankar Banerjee in response to Thomas Jung on page 23
Oct 29, 2014 1:32 PM
Thanks Thomas. I am currently checking this option only
...
My current requirement is to fetch Weather Data and Social Media data from various OData services and store
them in HANA for further analysis. What might be the best way for this? I am currently checking the option of
creating an XS application which would connect to the external services, fetch the data and save that in HANA
using DB Connection. Is this the best way? Or should we try to use JAVA or some other way?
Your valuable suggestions are most welcome. Thanks.
Regards
Tarasankar
Thomas Jung in response to Tarasankar Banerjee on page 23
Oct 29, 2014 12:56 PM
>However is it possible to consume XSODATA service from XSJS instead of using DB Connection?
You can via an outbound HTTP destination; although I certainly wouldn't recommend it. It would be rather
complex and not well performing.
>Also is it possible to consume data from external OData services for weather data, social media data etc from
XSJS?
Sure, with the same Outbound HTTP Connectivity.
https://www.youtube.com/watch?v=fWirvj9l7eY
Maintaining HTTP Destinations - SAP HANA Developer Guide - SAP Library
Tarasankar Banerjee
Oct 29, 2014 11:19 AM
Dear Thomas,
Thanks for the great blog!!
I am able to connect to Database and execute queries from XSJS service. However is it possible to consume
XSODATA service from XSJS instead of using DB Connection?
Also is it possible to consume data from external OData services for weather data, social media data etc from
XSJS?
If possible it would be great if you could provide some code sample or guidelines.
Thanks.
Regards
Tarasankar
Thomas Jung in response to Weiping Lu on page 24
Sep 25, 2014 8:33 AM
Please refer to service note 1849775:
http://service.sap.com/sap/support/notes/1849775
I believe it will address your issue.
Weiping Lu
Sep 24, 2014 5:19 PM
Hi Tom,
Great post and videos! I have a tough issue: calling a HANA procedure from XS takes > 5min, but from HANA
studio < 1 min. We're using Amazon AWS rev 70 and 73. Any help will be greatly appreciated.
Thanks,
WPL
Thomas Jung in response to Su Srikanth on page 24
Aug 11, 2014 2:53 PM
You transport XSODATA services like you would any other repository content - via a Delivery Unit.
Su Srikanth
Aug 11, 2014 7:50 AM
Hi Thomas,
Great blog!
I've a query here - we create the odata services(and/or URLs created to view in the web browser) in
development environment, now if we have to transport it to the quality and/or production environment, how
can we do this - is the same as import/export? or is there any specific way to do. please help with any useful
pointers..
Many thanks as always!
Su
Thomas Jung in response to ARSHAD SHAIKH on page 24
May 15, 2014 2:31 PM
I've never written any blogs on calculation views. I don't cover that topic. That is why I suggested you ask your
question in the proper SCN forum.
Although looking at your your above SQL Statement, I don't see why you couldn't do this directly in XSODATA
off of the table STATUS without the need for the calculation view or the SQLScript Procedure.
ARSHAD SHAIKH in response to Thomas Jung on page 25
May 15, 2014 11:54 AM
Hello Thomas..
I am new to hana. Please suggest me the blogs of you. related to calculation view that calling
procedures(procedures have out parameter).
I am trying to fetch the result of procedure in calc view and want to create odata service for that calculation
view.
procedure code goes like this:
--------------------------------------CREATE PROCEDURE TWEETS_TODAY(OUT OP BIGINT)
language SQLSCRIPT sql security invoker default schema "SOCIAL360" reads sql data as
BEGIN
SELECT COUNT(*) INTO OP FROM "SOCIAL360"."STATUS" WHERE CREATED_AT = CURRENT_DATE;
END
calc view code goes like this:
---------------------------------------/********* Begin Procedure Script ************/
BEGIN
DECLARE OP BIGINT;
CALL "SOCIAL360".TWEETS_TODAY(:OP,var_out);
END /********* End Procedure Script ************/
Thanks
-Arshad
Thomas Jung in response to ARSHAD SHAIKH on page 25
May 15, 2014 9:44 AM
Your question seems to have no relation to the content in this blog. Please consider instead asking general
HANA questions in the appropriate SCN Forum.
ARSHAD SHAIKH
May 15, 2014 9:17 AM
Hi Thomas,
I want to call procedures in calculation view, (procedures have out parameter.)
Please suggest me step by step procedure with example and supporting documents.
Thanks
ARSHAD SHAIKH.
Henrique Pinto in response to Blair Krotenko on page 26
Apr 16, 2014 7:11 PM
Hmm not really sure of that, I see it but that might be because I'm an employee.
But the .NET development partner I was working with was not enrolled in any kind of beta testing program and
they were able to download it, so I guess you should as well.
Make sure to go in the "Installation and Upgrades" menu and not the "Support Packages and Patches".
Go to http://service.sap.com/swdc -> Installations and Upgrades -> Browse our Download Catalog -> SAP InMemory (SAP HANA) -> SAP HANA ADO.NET 1.0.
Best regards,
Henrique.
Blair Krotenko in response to Henrique Pinto on page 26
Apr 16, 2014 6:56 PM
Thanks for the info Henrique, but I can't find it. I don't know if it is an authorization issue or do we need to be a
ramp-up customer to d/l and use a beta product?
Thanks,
Blair
Henrique Pinto in response to Thomas Jung on page 27
Apr 16, 2014 6:14 PM
The ADO.NET provider is available for download in the SAP Service Marketplace (in beta edition so far).
Thomas Jung in response to Kamal Jain on page 26
Apr 16, 2014 5:14 PM
For general OData structure and syntax I find that the Odata.org website is very helpful. For example on this
topic:
http://www.odata.org/documentation/odata-version-2-0/uri-conventions/
The syntax of a $expand query option is a comma-separated list of Navigation Properties. Additionally each
Navigation Property can be followed by a forward slash and another Navigation Property to enable identifying a
multi-level relationship.
The page also has some sample URLs.
Kamal Jain
Apr 16, 2014 5:36 AM
Dear Thomas,
I agree that we need to pass all the associations in the expand. I tried with some of options, but was not
through.
Now i just tried with below syntax and able to achive. Thx.
http://dewdftzld025.pgdev.sap.corp:8000/DTHCP/XS/ZPMIS_PRO_ACTUAL.xsodata/
ZPROHEADER('PR07_000002')?$expand=ZACTU/ZEMPD
Regards,
Kamal Jain
Thomas Jung in response to Blair Krotenko on page 27
Apr 15, 2014 6:23 PM
We do plan to release an ADO.NET provider specific to HANA in the near future. This would probably be the
best option for consumption from .NET. Until then I would think that ODBC is probably the next best option. It
gives you generally easy portability from already existing database code. You could consume OData as well,
although that is more generally consumed from the UI layer itself. It guess it somewhat depends upon where
you are calling the service from in your .NET application.
Blair Krotenko
Apr 15, 2014 4:09 PM
Hi Thomas,
We are looking at consuming HANA data in a .NET application and from what I can see, there are 2 options OData and ODBC. It seems to me that OData might be the better option when consuming HANA data in an XS
application, while ODBC might be the better option for .NET. What are your thoughts? Is there a paper on this
subject? I haven't been able to find a comparison document for this. Are there any security caveats to be aware
of for these options?
Thanks,
Blair
Thomas Jung in response to Kamal Jain on page 27
Apr 15, 2014 1:36 PM
You have to list both associations in the expand on the URL if you want both relationships to be processed.
Kamal Jain
Apr 15, 2014 12:49 PM
Hi Thomas,
Thx for valuable and useful information.
I have an query regarding XS Odata service creation for more than 2 tables and get all the data in one
command.
There is req. in which service needs to be created for 3 tables to get data from all these.
First table has Project ID as key, second table has composite
ProjectID and Employee Id as key and third table has Employee id as
key.
So if I create navigation for first 2 tables based on project id and use expand comand than its working fine and I
can see data of both the tables.
Further, if I add navigation for third table also as below, then below expand is displaying data for first two tables
only. Pls share how to use expand command in this case if possible to get all tables data based on project id.
How to use navigation ZEMPD here.
http://dewdftzld025.pgdev.sap.corp:8000/DTHCP/XS/ZPMIS_PRO_ACTUAL.xsodata/
ZPROHEADER('PR07_000002')?$expand=ZACTU&
service namespace
"DTHCP.XS" {
"DTHCP"."DTHCP.DB::HCP_PROJECT_HEADER"
as "ZPROHEADER"
navigates ("PROJECT" as
"ZACTU");
"DTHCP"."DTHCP.DB::HCPT_ZPMIS_ACTUAL"
as "ZACTU"
navigates ("EMPLOYEE" as
"ZEMPD" );
"DTHCP"."DTHCP.DB::HCP_ZPMIS_RES_MASTER"
as "ZEMPD";
association "PROJECT" principal
"ZPROHEADER"("PROJECTID")
Pls suggest if there is anything to add or correct in XS odata service syntax above.
Regards,
Kamal Jain.
Vikas Madaan in response to Thomas Jung on page 29
Apr 14, 2014 4:58 PM
Thanks Thomas,
Under which component?
Regards,
Vikas Madaan
Thomas Jung in response to Vikas Madaan on page 29
Apr 14, 2014 4:50 PM
No this isn't a known issue I've seen. Nor can I recreate the problem in my system. No you can't maintain the
authentication in XSHTTPDEST itself. It intentionally must be set in XSADMIN tool. I can really only suggest
that you open a support ticket.
Vikas Madaan
Apr 14, 2014 4:31 PM
Hi Thomas,
I am trying to pull data from SAP system onto HANA Database using XSJOB files. I am calling RFC enabled
function modules over HTTP request. It helps me replicating the real time ECC data onto HANA as well with
back ground jobs.
I am facing one problem in the XSHTTPDEST file. I am able to create and activate the file using studio and this
file is even visible in the web based XS administration tool. But in the web based tool when i provide user and
password for basic authotication then system just clears the user id and password when i try to save. This the
reason our HTTP requests are getting failed and below is the response we are getting in the response body.
<html><head><title>Logon Error Message</title>
Is this known issue or we are missing something? Is it possible to provide user and password in the
XSHTTPDEST file. Is there any particular syntax?
I checked and i have the required authorizations as well develper Guide.
Please help.
Regards,
Vikas Madaan
Abdul Hakim
Feb 22, 2014 3:59 AM
Hi Thomas - Any recommended book or resource to learn and master Server Side Javascript? There were
many books available in the market but as a beginner need to know the right resource / book to start with and
master this stuff..Also whether SAP plan to conduct any training to teach Server Side Javascript similar to other
standard training offerings?
Thanks
Hakim
Samuel Tanor-Gyedu
Feb 20, 2014 8:39 AM
Thanks Thomas
I will definitely have a look at SHINE.
Thomas Jung in response to gentilini andre on page 30
Feb 19, 2014 4:22 PM
Difficult to say what is wrong. I several things which are different than our sample that does this. You are using
a POST for instance instead of a GET. However if you are gettting a 200 then I assume the service call is
correct. In client side tools (like Chrome Developer Tools) you should be able to see the response object from
the call.
However what I would really recommend is that you study the SHINE content (SAP HANA Interactive
Education). There is already a sample application which does this in SHINE. Also it has some special
JavaScript in the UI to handle the file attachment via AXAJ call. Perhaps that is the part you are missing.
You can read more about SHINE here. It is also included already installed in the latest version of the HANA
Developer Center trial image (SP7 based).
http://help.sap.com/hana/SAP_HANA_Interactive_Education_SHINE_en.pdf
gentilini andre
Feb 19, 2014 3:25 PM
Hi Thomas,
well I followed your hints but it still dont work.
I created a xsjs File like below:
function downloadExcel(){
try {
var body = '';
alert('drin');
var query = 'SELECT "CompanyName", "PartnerId", "PostalCode", "City", "PurchaseOrderId",
"LifecycleStatus", "GrossAmount", "TaxAmount", "CM_NET_Amount_001", "Currency" FROM
"_SYS_BIC"."Workshop_001.PG1_BL_TI.ANGE1/CA_TBN_001" order by "PurchaseOrderId"';
var conn = $.db.getConnection();
var pstmt = conn.prepareStatement(query);
var rs = pstmt.executeQuery();
alert('drusse');
body =
"\tCompanyName \tPartnerId \tPostalCode \tCity \tPurchase Order Id \tLifecycle Status \tGross Amount
\tTax Amount \tNetto Amount \tCurrency \n";
while(rs.next()) {
body += rs.getString(1)+
"\t"+rs.getString(2)+"\t"+rs.getString(3)+"\t"+rs.getString(4)+"\t"+rs.getString(5)+"\t"+rs.getString(6)+"\t"+rs.getDecimal(7)+"\t"+
$.response.setBody(body);
$.response.contentType = 'application/vnd.ms-excel; charset=utf-16le';
$.response.headers.set('Content-Disposition','attachment; filename=Excel.xls');
$.response.headers.set('access-control-allow-origin','*');
$.response.status = $.net.http.OK;
} catch (e) {
alert('db conn funktioniert nicht');}
}
var a = $.request.parameters.get('cmd');
$.response.setBody('Invalid Command: '+a);
switch (a) {
case "doex":
$.response.setBody('Invalid Command: '+a);
alert("filedownload");
this.downloadExcel();
break;
default:
$.response.status = $.net.http.INTERNAL_SERVER_ERROR;
$.response.setBody('Invalid Command: '+a);
}
The Controller.js File:
jQuery.sap.require("sap.ui.commons.MessageBox");
//
sap.ui.commons.MessageBox.show("Export Starten?", sap.ui.commons.MessageBox.Icon.confirm,
"Information");
//
//
function inform(rValue){
alert ("drinnnnne!");
var aurl = "FileDownload.xsjs?cmd=doex";
if(rValue) //If User presses 'Ok'
{
alert(aurl);
jQuery.ajax({
url: aurl,
method: "POST",
dataType: "json",
data:{cmd:"doex"},
success: sap.ui.commons.MessageBox.alert("Export wird ausgefhrt!",'',"Confirmation"),
error:function onErrorCall(jqXHR, textStatus, errorThrown){
alert(jqXHR.status);
sap.ui.commons.MessageBox.show(jqXHR.status,
"ERROR",
"Error in calling Service" );
return;
},
complete: sap.ui.commons.MessageBox.alert("Export Erfolgreich
abgeschlossen!",'',"Confirmation")
});
//
return false;
}
else // If the user presses 'Cancel'
{
sap.ui.commons.MessageBox.alert("Vorgang abgebrochen!",'',"Notification");
}
});
lite: true
}).placeAt("btn");
oButton3.attachPress(oController.doFileDownload);
//
//
//
jQuery.sap.require("sap.ui.table.Table");
// create table control with properties
var oTable = new sap.ui.table.Table({
width : "100%",
rowHeight : 50,
title : "Amount per Partner",
selectionMode : sap.ui.table.SelectionMode.None
});
oTable.addColumn(new sap.ui.table.Column({
label : new sap.ui.commons.Label({
text : "Company Name"
}),
template : new sap.ui.commons.TextView({
text : "{CompanyName}"
})
,sortProperty : "CompanyName"
}));
oTable.addColumn(new sap.ui.table.Column({
label : new sap.ui.commons.Label({
text : "Partner ID"
}),
template : new sap.ui.commons.TextView({
text : "{PartnerId}"
})
,sortProperty : "PartnerId"
}));
oTable.addColumn(new sap.ui.table.Column({
label : new sap.ui.commons.Label({
text : "Postal Code",
textAlign : sap.ui.core.TextAlign.End
}),
template : new sap.ui.commons.TextView({
text : "{PostalCode}",
textAlign : sap.ui.core.TextAlign.End
}),
sortProperty : "PostalCode"
}));
oTable.addColumn(new sap.ui.table.Column({
label : new sap.ui.commons.Label({
text : "City"
}),
template : new sap.ui.commons.TextView({
text : "{City}"
}),
sortProperty : "City"
}));
oTable.addColumn(new sap.ui.table.Column({
label : new sap.ui.commons.Label({
text : "Purchase ID"
}),
oTable.addColumn(new sap.ui.table.Column({
label : new sap.ui.commons.Label({
text : "Lifecycle Status"
}),
template : new sap.ui.commons.TextView({
text : "{LifecycleStatus}"
}),
sortProperty : "LifecycleStatus"
}));
oTable.addColumn(new sap.ui.table.Column({
label : new sap.ui.commons.Label({
text : "Gross Amount"
}),
template : new sap.ui.commons.TextView({
text : "{GrossAmount}"
}),
sortProperty : "GrossAmount"
}));
oTable.addColumn(new sap.ui.table.Column({
label : new sap.ui.commons.Label({
text : "Tax Amount"
}),
template : new sap.ui.commons.TextView({
text : "{TaxAmount}"
}),
sortProperty : "TaxAmount"
}));
oTable.addColumn(new sap.ui.table.Column({
label : new sap.ui.commons.Label({
text : "Amount Netto"
}),
template : new sap.ui.commons.TextView({
text : "{CM_NET_Amount_001}"
}),
sortProperty : "CM_NET_Amount_001"
}));
oTable.addColumn(new sap.ui.table.Column({
label : new sap.ui.commons.Label({
text : "Currency"
}),
template : new sap.ui.commons.TextView({
text : "{Currency}"
}),
sortProperty : "Currency"
}));
});
It wont call the function or better said the action of the button works fine till to the point where it should call the
xsjs.file to generate the excel-file. I wondered that in the ajax part the error-, success- and complete-part will
be executed at the same time, and not only one of this statements. The message is "200" (The request has
succeeded. The information returned with the response is dependent on the method used in the request).
Maybe you can see where my mistake is, or whats going wrong?
Ive the developer edition on cloudshare (Hana Studio rev.68; Server is on SPS05).
Thanks
Andr
Thomas Jung in response to Samuel Tanor-Gyedu on page 38
Feb 19, 2014 5:23 AM
I don't think I can help you. This appears to a question about how odata4j works not about XS. I have no
experience with odata4j myself.
Samuel Tanor-Gyedu
Feb 18, 2014 9:13 AM
Hi Thomas,
I have an odata service with this endpointhttps://s5hanaxs.hanatrial.ondemand.com/.../services/User.xsodata
I am now trying to consume it from eclipse with the odata4j libraries.
This is how I get the endpoint.
public UserServiceOdata(String endpointUri) {
this.endpointUri = endpointUri;
ODataConsumer.dump.responseHeaders(true);
consumer = ODataConsumers.create(endpointUri);
}
This is my method to add a user.
public User addUser(User user) {
consumer.createEntity(entitySet).properties(OProperties.int32(propertyUserId,
user.getId())).properties(OProperties.string(propertyUserName,
user.getName())).properties(OProperties.string(propertyUserEmail,
user.getEmail())).execute();
return user;
}
When I call addUser method I get an Error:
Caused by: javax.xml.stream.XMLStreamException: ParseError at [row,col]:[78,253]
Message: The reference to entity "sourceUrl" must end with the ';' delimiter.
Im pretty new in SAPUI5 and tried your export-sample in my little trial project, but it doesnt work
else{
body += rs.getString(1)+
"\t"+rs.getString(2)+"\t"+rs.getString(3)+"\t"+rs.getString(4)+"\t"+rs.getString(5)+"\t"+rs.getString(6)+"\t"+rs.getDecimal(7)+"\t"+
} $.response.setBody(body);
$.response.contentType = 'application/vnd.ms-excel; charset=utf-16le';
$.response.headers.set('Content-Disposition','attachment; filename=Excel.xls');
$.response.headers.set('access-control-allow-origin','*');
$.response.status = $.net.http.OK;
}
</code>
Im afraid and hope that you can help me.
Kind regards
Andr
Thomas Jung in response to Vikas Madaan on page 41
Feb 11, 2014 12:46 PM
>Is there any restriction or development limitation in the XSJSLIB files?
That's a very general question. Difficult to answer without any context.
Vikas Madaan in response to Thomas Jung on page 41
Feb 11, 2014 12:45 PM
Thanks Thomas.
I think we are on same page.
Once quick question that came to my mind: Is there any restriction or development limitation in the XSJSLIB
files?
Regards,
Vikas Madaan
Thomas Jung in response to Vikas Madaan on page 41
Feb 11, 2014 12:30 PM
>Could please help me in understanding in more advantages/disadvantages for both techniques?
You've summarized it pretty well already.
>becuase i don't want to use both the approaches
Even with the CRUD support and exits in XSODATA, its still pretty hard to do 100% via XSODATA. There are
still valid use cases for XSJS when you need custom body, custom read processing, job scheduling, etc. Its
good to try and use XSODATA whenever possible, but I wouldn't automatically exclude the use of XSJS.
Vikas Madaan
Feb 11, 2014 10:08 AM
Hi Thomas,
Thanks a lot for sharing useful information through various blogs.
In my current project we are evaluating use of XSOData or XSJS applications. I saw your videos like the one
mentioned below:
http://www.saphana.com/docs/DOC-4376
Want i understood from various blog is this:
From SP7 we can write exsits in the OData services and it is very easy to consume at the client side just like
any REST base service and from my understanding it is Scalable as well. I would love to use XSOData always
becuase development effort is very less compare to XSJS and it is very easy to rampup the team on OData
related development objects.
XSJS were as provide more control becuase of server side scripting becuase it allows development on the
server side using JavaScript. Core APIs of SAP HANA Extended Application Services are, therefore, exposed
as JavaScript functions; providing easy access to the HTTP Request and Response object as well database
access to execute SQL or call SQLScript Procedures. It provide us control over the body format and and URL
parameter definition.
Could please help me in understanding in more advantages/disadvantages for both techniques?
I am very keen to understand and also explain the same to team members becuase i don't want to use both the
approaches and even sometimes customer can also ask the same to us.
Also If we are on SP6 then from my understanding XSJS provides us more capability in terms of complex
application. Corrent me If i am wrong.
Thanks!
Regards,
Vikas Madaan
Thomas Jung in response to Raghuveer Phull on page 42
Feb 5, 2014 3:12 PM
Yes there are videos on the CRUD features of XSODATA which were new in SP6:
For more on CRUD support in SP6, see this video:
oData Create/Update/Delete Support in SAP HANA SPS6
For the extended support for XSJS exits in SP7, see this video:
SAP HANA SPS 07 XSODATA Exits in XSJS
Raghuveer Phull
Feb 5, 2014 1:22 AM
Do you have an example/documentation/video where you can write a service which will populate Hana DB ?
What I am asking for is a way for my external script to populate the DB tables i have created in Hana DB.
Thomas Jung in response to reda miraoui on page 43
Jan 29, 2014 4:11 PM
The source code for the examples shown here are shipped as part of SHINE (SAP HANA Interactive
Education):
http://help.sap.com/hana/SAP_HANA_Interactive_Education_SHINE_en.pdf
Vivek Singh Bhoj in response to reda miraoui on page 43
Jan 29, 2014 3:52 PM
Hi Reda,
You can import Shine Content in HANA and then check all these source codes
http://help.sap.com/hana/SAP_HANA_Interactive_Education_SHINE_en.pdf
Regards,
Vivek
reda miraoui in response to Thomas Jung on page
Jan 29, 2014 3:44 PM
Hey Thomas,
Is it possible to download source code of your project from this HANA tutorial?
Thanks
Reda
Thomas Jung in response to Abdul Hakim on page 43
Nov 21, 2013 11:33 PM
Yes River can be used as an alternative and when activated it will generate Server Side JavaScript and/or
SQLScript.
Abdul Hakim in response to Thomas Jung on page 44
Nov 21, 2013 7:47 PM
Hi Thomas - Was going through blog regarding River (RDL)...Just a question on this...
When you say Programming language for HANA native development is Server side Javascript / SQL / SQL
Script..Once RDL is rolled out whether RDL can be used for native application development instead of Server
side Java script / SQL / SQL Script?? I am very much new to this stuff so appreciate if you can also help on
how to get started with Server Side Java script / SQL / SQL Script for HANA...
Thanks
Hakim
ashutosh dixit in response to Thomas Jung on page 45
Oct 30, 2013 7:50 AM
Hi Thomas ,
Thanks for your response , I am talking about more content on shine.
thanks
Ashutosh
ABAP
applications follow 3-tier architecture
ABAP is in general database agnostic, but with release 7.4 optimized for SAP HANA
Programming language: ABAP / ABAP OO with the option to use SAP HANA features
IDE: eclipse-based ABAP Development Tools
HANA Native Development
applications follow 2-tier architecture
HANA Native Development is SAP HANA specific and embedded in the database
Programming language: River; server-side JavaScript, SQL/SQLScript
IDE: eclipse-based SAP HANA Studio + web IDE
As this content is now standard in SP6 as part of SHINE (SAP HANA INteractive Education), there also some
setup instructions on help.sap.com
http://help.sap.com/hana/SAP_HANA_Interactive_Education_SHINE_en.pdf
Basic points to check - have you generated the synonyms in the data generator? Ran the data generator to
create some data? Have the role assigned? Added client 001 to your user profile?
ashutosh dixit
Oct 24, 2013 1:30 PM
Hi Thomas ,
Amazing blog - once again Thomas, thanks.
I have been following you for many days , attended your OPEN SAP course also.
That was an amazing course for new learner like me .
One of our client is looking forward for XS based search Application identical to what you have created in your
DEMO.
But I am not able to fetch the data on blank HTML page is coming with no data .
If there is any step by step document related to this please help in getting that .
Any help will be highly appreciated.
Thanks
Ashutosh
Naveen Kumar
Sep 26, 2013 11:30 AM
Good Document...
Heber Fabiano
Aug 27, 2013 3:23 PM
Great content as always. Keep sharing with us.
Thomas Jung in response to Orel Stringa on page 48
Aug 27, 2013 1:47 PM
This is currently not possible. The CORS support is for all origins. We don't yet have the feature to maintain a
whitelist of CORS origins.
Orel Stringa in response to Thomas Jung on page
Aug 27, 2013 8:01 AM
Hi Thomas,
nice to see that SAP has made it possible with SP6 to specify cross origin resource sharing (CORS) support
via the .xsaccess file. SP6 HANA development guide has example of how to specify CORS support.
I have build an XS application and would like to serve SAPUI5 on a diff.host than XS/HANA.
How can I specify that I would like to allow cross origin access restricted to certain domain(s) only ?
Is there a special keyword / syntax for specifying that?
Thank yoi.
Orel
Vijay Uthayakumar
Aug 27, 2013 1:31 AM
Highly informative & digestible! Fantastic work!
Jerry Wang
Aug 1, 2013 9:55 AM
Hi Tomas,
Thank you.
Jerry
Thomas Jung in response to Milan Vrozina on page 49
Jul 21, 2013 6:44 PM
JSLint checks are very strict and often produce syntax errors for items that just stylistic and won't actually
cause an error upon activation or runtime. You can either ignore the JSLint errors or deactivate JSLint for this
project in these cases. However it might also be an indication that the JavaScript code you are trying to import
isn't compatible with Strict mode.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions_and_function_scope/
Strict_mode
Milan Vrozina in response to Thomas Jung on page 49
Jul 21, 2013 6:24 PM
Thanks for clarification. I thought there would be some kind of import.
But anyway, in case of this specific library I have some problems with JSLint validation when I do cut and paste
of the original code.
Thomas Jung in response to Milan Vrozina on page 49
Jul 21, 2013 3:43 PM
What kind of problem are you having using this library? Strict mode JavaScript which doesn't try to access the
DOM, Window, or other client side specific objects should work in Server Side XSJS. Generally if you have a
library you just cut and paste into your XSJS or an XSJSLIB file and then call the functions from your code.
Milan Vrozina
Jul 21, 2013 3:39 PM
Hello,
first and foremost, thank you for perfect openSAP classes related to HANA development and for this blog as
well.
I have one question related to server-side javascript. You mentioned in course, that is possible to use 3rd party
libraries or reuse 3rd party code. But I can't find a possible way how to import 3rd party javascript library -as
is- to server and use it. For example I would like to use JSZip library to zip some file, before sending it to client
from xsjs application. Is that possible ? Thank you.
Chandrashekhar Mahajan
Jul 3, 2013 7:34 PM
This is excellent blog! Now HANA XS is very much clear to me
Mohan krishna
Jul 1, 2013 1:44 PM
WOW - great blog Thomas! This will be very helpful in understanding SAP hana .Good Job
Thanks
Chandra
Thomas Jung in response to Alexander Bauer on page
Jun 3, 2013 8:56 PM
SAPUI5 gets updated auutomatically when you apply HANA revisions. There is no additional download or
update needed.