Skip to content

A simple package with tables, views and an oData service to be consumed on SAP products or third party applications

License

Notifications You must be signed in to change notification settings

NickChecan/HanaService

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Hana Service

The purpose of this project is to implement a simple SAP Hana solution with some basic components to serve and demonstrate the integration between a common third party application to a SAP Hana database.

Note:

  • A SAP Cloud Platform account will be required in order to maintain a Hana Trial instance for your project.
  • This project was meant to run on a HANA MDC instance from the Neo environment of the SAP Cloud Platform trial.
  • The implementation of this application was made to be the first step for the HanaToPython and/or HanaToJava project deployment.

Project Components

This project consist in the creation of three tables, three common views, one database schema and a calculation view.

HanaService
	├── Analytics
	│    └── CV_SALES_SUMMARY.calculationview
	├── CDSScripts
	│    ├── SALES_TUTORIAL.hdbschema
	│    ├── SalesDDL.hdbdd
	│    └── SalesDML.sql
	├── SQLScripts
	│    ├── SalesDDL.sql
	│    └── SalesDML.sql
	├── Services
	│    └── api.xsodata
	├── xsjs
	│    ├── delete.xsjs
	│    ├── example.xsjs
	│    ├── insert.xsjs
	│    ├── read.xsjs
	│    └── update.xsjs
	├── SalesData.calculationview
	└── README.md

All the tables creation and data preparation will be performed within the scripts at the CDSScripts folder.

It is important to notice that the files available at the SQLScripts folder is for merely demonstration. Although, you can use these scripts to prepare and study the development environment behavior or other implementation scenarios.


Getting Started

Before importing this project to your Hana workspace, it is necessary to make sure the prerequisites steps are properly done in your development environment. The installation procedure described in this documentation will assume you've already properly connected your eclipse IDE to your Hana Trial instance.

Prerequisites

  • Hana Trial Instance
    The Hana trial instance should be created through the SAP Cloud Platform cockpit using the HANA MDC1 database system in the Database & Schemas area.

  • SAP Cloud SDK
    The SAP Cloud Platform Neo Environment SDK2 will also be necessary to open a database tunnel3. This tool can be downloaded from the SAP Development tools at the Cloud tab.

  • Eclipse plugins
    To install the Hana Eclipse tools, you can follow the simple procedure described here for your current eclipse installation.

Note:

  • This project uses the Java Web Tomcat 8 3.48.12 SDK.
  • Remember to make sure the tools folder of the downloaded content is properly registered in the path of the system environment variables.

Installing

The steps bellow will guide you through the project installation. The same will automatically create the database schema, his tables and views through the CDS4 script activation.

  1. Clone the project to your local repository workspace;
  2. Refresh your Repositories tree and make sure the cloned project is available in the selected workspace;
  3. Right click in the project package and select the "Check Out and Import Project" from the context menu. This step will make the same available at the Project Explorer for further enhancements;
  4. Active the imported project;

After the activation process, the schema objects will only be visible in the catalog to the _SYS_REPO user. To enable other users, for example the schema owner, to view the newly created schema and the objects it contains, you must grant the user the required SELECT and INSERT privilege for the appropriate schema object through the following command:

CALL _SYS_REPO.GRANT_SCHEMA_PRIVILEGE_ON_ACTIVATED_CONTENT('SELECT, INSERT','SALES_TUTORIAL','<User>');

Although these steps will create and prepare the test environment, the scripts activation mentioned above will not automatically load content in the created tables. To properly insert data in these tables, you can execute the code available at the CDSScripts/SalesDML.sql script or prepare your own data for test purpose.


Deployment

With all the database components properly created and prepared, the database tunnel can be set to enable other SAP or third party applications to access these information's. To make this possible you will have to use the following command at your terminal:

neo open-db-tunnel -i <Database/Schema ID> -a <Subaccount Name> -h hanatrial.ondemand.com -u <SAP User>

As soon as the command is processed, the user password will be requested. If the tunnel is opened successfully, the terminal will display the Host name, Database type, JDBC Url and the instance number. These information's will be useful to properly connect the mentioned applications to this Hana Service.

Tips:

  • Always remember to make sure the created instance is up and running through the Cloud Platform Cockpit before execute commands or test any application directly linked to this Hana Service.
  • You can find more information about the neo open-db-tunnel command here.

Acknowledgments

The database diagram used in this service was provided by the SAP Hana tutorial web site. The learning materials there are simply AWESOME and totally worth attention.

The SAP blogs has proven to be a great reliable source of information for developers to study and be up to date with new SAP technologies and products, and also helped me a lot with the purpose of this project.

You can find more information about CDS entities and their management here.

1: SAP HANA supports multiple isolated databases in a single SAP HANA system. These are referred to as multitenant database containers. More information here.

2: The Neo environment is an SAP Cloud Platform proven development environment that lets you develop HTML5-based, SAP HANA XS, and complex Java applications. More information here.

3: A database tunnel allows you to connect to a remote database instance through a secure connection. More information here.

4: Core Data Services are scripts to build design-time data-persistence models in SAP HANA Extended Application Services. More information here.