Install Database Package (OPTIONAL) - SAP-archive/fiori-for-ios-workshop GitHub Wiki

#Deprecated: Use this tutorial guide instead

This guide will show how to create a HANA Database and build an OData Service on top of it. This is all optional as an other tutorial shows how to deploy a working Odata Service.

Create Database

In SAP Cloud Platform Cockpit, Neo Trial, select SAP HANA / SAP ASE > Database & Schemas. Click New to create a new Database.

Enter name expensedb for the database, and create a SYSTEM user password. Note that the system user password must be 15 char with lower/upper-cased characters. Write this down, as you will need it in a later step

Existing settings may be left as-is. Click Create to create.

You'll be navigated to the Events window, where you can monitor the creation status for the few minutes it will take to create the db.

You may safely navigate from the Events window. When completed, an Event will be created named "Tenant DB creation finished successfully (created and configured)".

Create DB developer user, and grant permissions

The SYSTEM user should not be used for developing on the database, so you'll need to create a developer user which will have rights to import and publish the database package.

While on the Database: expensesdb - Overview page, click on the Overview tab, click on the Administration Tools: SAP HANA Cockpit link, and log-in with the SYSTEM user and password you created above.

You'll be informed that you do not yet have the requisite privileges; click "OK", and they will be granted to you.

When completed, you will land on the SAP HANA Database Administration dashboard.

Select Manage Roles and Users.

Navigate in the explorer to Security > Users > SYSTEM, and CTRL+Click on SYSTEM. Click on Copy User.

A new userID will be proposed, and you need to supply a user password. When submitted, the Job Log will indicate that they copy is in state "To be reviewed", and you can close the log box.

Note: the console may indicate that a number of privilege grants have failed due to insufficent privileges. For the purpose of this project, you may ignore these warnings.

Switch to the newly created developer user (USER1 by default) in Security > Users, switch to the Granted Roles tab, and click the green + button to add privileges.

Your developer user should have Administration and Developer privileges. For convenience, we'll add all of both category.

Search for the string ADMIN, select all results, and click "OK".

Repeat this process for the search string: Developer. 'Command+S' to save the changes to your new user.

Switch to new user, and import Delivery Unit

Make sure you remember your passwords for both SYSTEM and your new developer user (USER1). You'll need to switch between them.

Click the 'power' button in the upper right to log-out as SYSTEM, so that you can log back in as USER1 (or your own Developer user ID).

After logging out as SYSTEM, enter the user ID and password of your developer user to log in as your Developer (USER1). You'll immediately be prompted to change the developer user's password.

Once successful, you can close this window, and return to the SAP Cloud Platform Cockpit > Database Overview page from above. Now, navigate to Administration Tools: SAP HANA Cockpit. Scroll down on the dashboard, and select SAP HANA Application Lifecycle Management > Manage Products and Delivery Units.

Switch to the Products > Delivery Units tab, and click Import. Click the Browse button to locate and select the Delivery Unit file named DatabasePackage.tgz in the root of the repository. Click Import again, on the Confirm Import page. When successful, the view will refresh momentarily, and you should see a new Delivery Unit named SAPDEVS_SAPEXPENSE, and it should own a set of Packages with prefix of codejam.saptravelexpense.

Grant codejam privileges to USER1

Close the SAP HANA Application Lifecycle Management tab in your browser. Switch back to the tab for SAP HANA Cockpit.

Log out of USER1 by clicking the drop-down in the upper right, and log back in as SYSTEM user.

In some cases, upon logging out as USER1, the cookie state in the browser will immediately log you back in correctly as SYSTEM, in which case you can proceed.

In the SAP HANA Database Administration dashboard, select Manage Roles and Users. In the SAP HANA Web-based Developent Workbench: Security tool, select USER1, and switch to the Granted Roles tab.

Click the 'plus' button, and search for the string codejam.

Select the available role, and click "OK". Save.

Log out of SYSTEM user (for the last time), and back-in as USER1 (or your userID)

Verify connectivity via OData

At this point, your user should be able to access the database via OData. To verify this try the following URL:

https://<database name><hana trial name>.hanatrial.ondemand.com/codejam/saptravelexpense/services/travelexpense.xsodata/ExpenseReportItem

//e.g.:
https://expensedbi826181trial.hanatrial.ondemand.com/codejam/saptravelexpense/services/travelexpense.xsodata/ExpenseReportItem

You should see a regular OData response, with one or more expense report entries.

You may also use a REST client, such as Postman, which can provide Basic auth headers.

If you receive an authorization error (403), make sure you have logged out as SYSTEM, and are logged in as USER1 (or your own Developer userID)

If you receive privileges error (258), go back to the USER1 role granting for "codejam", and ensure it was properly added.