28.01.2013 Views

SAP HANA Developer Guide - Get a Free Blog

SAP HANA Developer Guide - Get a Free Blog

SAP HANA Developer Guide - Get a Free Blog

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

In addition, the <strong>SAP</strong> <strong>HANA</strong> Repositories view shows that a new hierarchy of packages has been created based<br />

on the name of your project, mycompany.myorg.testing.<br />

4.5.6 Write Server-Side JavaScript<br />

Now let's write some code. As a first step, to make sure everything is working OK, you will simply output Hello,<br />

World!.<br />

You will have to create three files:<br />

● .xsjs: This contains your code.<br />

● .xsapp: This indicates that everything in your package can be exposed via HTTP. You still need to explicitly<br />

expose the content and assign access controls.<br />

● .xsaccess: Exposes your content, meaning it can be accessed via HTTP, and assigned access controls.<br />

1. Right-click your project, and select New Other .<br />

2. Select <strong>SAP</strong> <strong>HANA</strong> Development XS JavaScript Source File .<br />

3. In File name, call your JavaScript file MyFirstSourceFile.xsjs, and select Finish.<br />

The file, which is blank, opens in the JavaScript editor.<br />

4. In the MyFirstSourceFile.xsjs file, enter the following code:<br />

$.response.contentType = "text/html";<br />

$.response.setBody( "Hello, World !");<br />

This uses the <strong>SAP</strong> <strong>HANA</strong> XS JavaScript API's response object to write out HTML. By typing $. you have<br />

access to the API's objects.<br />

5. Add a blank file called .xsapp (no name, just a file extension) by right-clicking to the root of your project.<br />

70<br />

More on this later.<br />

To add a file, right-click the project and select New File , enter a file name, and select Finish.<br />

P U B L I C<br />

© 2012 <strong>SAP</strong> AG. All rights reserved.<br />

<strong>SAP</strong> <strong>HANA</strong> <strong>Developer</strong> <strong>Guide</strong><br />

Setting Up Your Application

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!