Skip to Content
Author's profile photo Rabiul Chowdhury

Getting Started with HANA XS Application on SAP Cloud Platform

In SAP Newtown Square there is a place called the D-Shop (Developers Workshop). The D-Shop is a place to meet and collaborate, to explore and learn, to play and, of course, to invent and build. My first project at SAP was to create an inventory app for the D-Shop (Developer Workshop), and I was responsible for implementing the backend system for the project on HCP.


It was a new challenge for me to get started on SAP’s new HANA Web-based Development Workbench, since I just started programming. However, I realized that knowing only how to code doesn’t always solve the problem, you also need to understand the tools that you are using. I had about 3 days of HANA training when I started my internship earlier this year at SAP. The training was focused on using HANA Studio, but my mentor gave me the opportunity to work on the new HANA SPS11 to create XS application. In HANA SPS11 I can not only do Data Modeling but I can also do frontend design. With that said, I decided to share my experience on how I learned to create an XS application.



Pre-Requisites: Getting Access to the right system!

If you don’t have access:

Helpful tutorial:


                                                                 STEP 1


In the blank package or application created, create a database SCHEMA with your new package that you have created.

**Remember it is very important that your SCHEMA name looks exactly the same as the file you have created since it’s case sensitive**


schema_name=”Your Schema name”;


                                                                    STEP 2

Next, create three new files within your XS package. The first file will be called “.xsprivileges”.This file defines the privileges required to access an application.


"privileges": [{
"name": "Basic",
"description": "Basic usage privilege"

The second file will be called .xsaccess. This file determines whether or not package content can be exposed and specifies the authentication method to be used to grant access.


1. {
2. "exposed": true,
3. "authentication": [{
4. "method": "Basic"
5. }],
6. "authorization": ["YourSchemaName"::Basic"]
7. }


The third file will be called “.xsapp”. This file marks the root point in the package hierarchy from which content can be served. There should only be curly brackets {} within this file. You can also click on “insert snippet”, button which is located to the right of the save button.

(This was one of the challenges that I faced because I kept on getting a 404 error.
This file is a must!)





                                                                 STEP 3

Create a sub package within the original package. Name it roles.
(Creating a new package with roles is not required, but I like to do it because it organizes my files). Now create a file under the package “roles” and name it  <your-file-name>.hdbrole. This file contains the defined application privileges.


role thedshop.roles::user {
sql object thedshop.procedures::createItems: EXECUTE;
    sql object SELECT;
application privilege: thedshop::Basic;

                                                                                          STEP 4


Then, under the SCHEMA created, create <file-name>.hdbdd file. HDBDD stands for Hana Data Base Data Dictionary. HDBDD contains all of your Data Base tables and table types.


@Schema: 'THEDSHOP'
context inventory {
type myKeyType: String(60);
Entity ShopItems {
key itemId: Integer;
name: String(50);
description: String(140);
serialNumber: String(100);
quantity: Integer;
images: CLOB;
context procedures{
type items {
itemId: Integer;
name: String(50);
description: String(140);
serialNumber: String(100);
quantity: Integer;
images: CLOB;
  type errors {
            HTTP_STATUS_CODE : Integer;
            ERROR_MESSAGE : String(100);
            DETAIL : String(100);


                                                             STEP 5

It is good to create CSV file if you are providing mass data from your backend system. CSV stands for Comma Separated Value. Also it is better to create a new package under your original package for .hdbti, .hdbdd, and .csv files so your files are organized.


                                                             STEP 6


Create file <your-file-name>.hbdti. This file will represent the Hana Data Base Table Import.

(In the table-import configuration, the table, cdstable, and hdbtable, the keywords can allow us to specify the name of the target table into which the table-import operation must insert data.)

The target table specified in the table-import configuration can be a runtime table in the catalog or a design-time table definition, for example, a table defined using either the .hdbtable or the .hdbdd (Core Data Services) syntax.



import = [
    table = "";
    schema = "THEDSHOP";
    file = "";
    header = false;

                                                                 STEP 7

Create Stored Procedure.
(**Recommendation: Create a separate package under original package for procedures to allow the creation of multiple procedure files under the package “procedure”**)

A stored procedure is a set of Structured Query Language (SQL) statements with an assigned name that’s stored in the database in compiled form, so that it can be shared by a number of programs.



PROCEDURE "THEDSHOP"."thedshop.procedures::createItems"(
IN intab "THEDSHOP"."",
OUT outtab "THEDSHOP".""
DECLARE lv_description STRING;
DECLARE lv_serialNumber STRING;
DECLARE lv_quantity INTEGER;
DECLARE lv_images NCLOB;
SELECT "itemId",
INTO lv_itemId,
FROM :intab;
IF (:lv_name = '') THEN
outtab = SELECT 500 AS http_status_code,

i. 'Invalid name ' || lv_name AS error_message,
ii. 'No Way! Item name must not be empty' AS detail
iii. FROM dummy;
INSERT INTO "" VALUES("".NEXTVAL, lv_name, lv_description, lv_serialNumber, lv_quantity,lv_images);

                         STEP 8

                      (Recommendation: Create a .hdbsequence file. This will auto generate your primary key.


schema= "THEDSHOP";
start_with= 24;
maxvalue= 1000000000;
minvalue= 24;
cycles= false;
depends_on_table= "";

                                                  Final Step


The final step is to create an XSODATA service. Again, it is better to create a separate package for all the XSODATA services. The OData service definition is the mechanism you use to define what data to expose with OData, how, and to whom.


service {
"YourSchemaName::NameOfYourhdbddFile.TableName" as "Contact"
create using "YourSchemaName.procedures::tableName";

Thanks for reading!

Assigned Tags

      You must be Logged on to comment or reply to a post.
      Author's profile photo Former Member
      Former Member

      Excellent information!!! Thank you for sharing!

      Author's profile photo Paul Aschmann
      Paul Aschmann

      Thanks for sharing your experiences Rabiul Chowdhury

      Author's profile photo Keerthan Aladangady
      Keerthan Aladangady


      I dont get the logic behind sequence file statement

      depends_on_table= "";


      It is asking to give a table name, I believe all tables reside in a schema and you have given package name, I am stuck at this point as I dont know how to put my table name which is "SYSTEM"."Z_MY_TABLE1"

      Author's profile photo Rabiul Chowdhury
      Rabiul Chowdhury
      Blog Post Author

      Hi Keerthan,

      depends_on_table should be your namespace,context, and the table name.

      For Example,