SAP HANA 4. Retrieve Data from SAP HANA.(Helloworld)

1、操作步骤

1.1Add an SAPHANA System.没有SAP HANA环境想要学习的同学,可以考虑申请SAP HANA Trials,试用30天,体验一下。附链接

http://global.sap.com/software-free-trials/index.epx?url_id=text-us-header-freetrials

 

 

SAP HANA 4. Retrieve Data from SAP HANA.(Helloworld)_第1张图片

 

SAP HANA 4. Retrieve Data from SAP HANA.(Helloworld)_第2张图片

 

SAP HANA 4. Retrieve Data from SAP HANA.(Helloworld)_第3张图片

 

 

1.2Add a Repository Workspace

SAP HANA 4. Retrieve Data from SAP HANA.(Helloworld)_第4张图片

1.3新建XS ProjectOPENSAP1如下图所示

SAP HANA 4. Retrieve Data from SAP HANA.(Helloworld)_第5张图片

 

1.4新建.xsapp.xsaccess。其中.xsapp文件内容为空,作为应用程序描述符(Application descriptor)标记web内容的root.xsaccess文件作为Application access文件,一是Exposes Web content,二是Setsuser/clientauthentication mechanism。根据OPEN SAP公开课程,在.xsaccess中写代码如下:

 
 
{
"exposed":true,
"authentication":[
{
"method":"LogonTicket"
},
{
"method":"Basic"
}
]
}


1.5新建XS JavaScript Source FileRetrieveData.xsjs,添加代码如下

$.response.contentType= "text/html";
var output ="Hello World! <br><br>";
var conn =$.db.getConnection();
var pstmt =conn.prepareStatement("select * from DUMMY");
var rs =pstmt.executeQuery();
if (!rs.next()) {
$.response.setBody("Failed to retrieve data");
$.response.status =$.net.http.INTERNAL_SERVER_ERROR;
}
else {
output = output +"This is the response from my SQL: "
+ rs.getString(1);
}
rs.close();
pstmt.close();
conn.close();
$.response.setBody(output);



1.6 Project OPENSAP1 Teamshare Projectcommitactivate,在浏览器中输入http://<Myserver>:8000/WorkShop/sessiona/RetrieveData.xsjs

 

 

2、发现错误及解决办法

2.1在浏览器中输入http://<Myserver>:8000/WorkShop/sessiona/RetrieveData.xsjs,回车后发现如下错误:

500 -Internal server error

An error occurredduring the processing of your request.

Data might be lost.

 

 

2.2SCN中链接如下内容http://scn.sap.com/thread/3398193#

SAP HANA 4. Retrieve Data from SAP HANA.(Helloworld)_第6张图片

下载SPS6SAP_HANA_Developer_Guide_en.pdf,将.xsaccess内容修改为

{"exposed" : true, "authentication" : [ { "method": "Basic" } ] }




修改完,Team CommitActivate,然后浏览器中输入

http://<Myserver>:8000/WorkShop/sessiona/RetrieveData.xsjs,显示如下

SAP HANA 4. Retrieve Data from SAP HANA.(Helloworld)_第7张图片

程序运行成功。

 



   

你可能感兴趣的:(HANA,SAP,内存计算,列存储)