Technology Blogs by SAP
Learn how to extend and personalize SAP applications. Follow the SAP technology blog for insights into SAP BTP, ABAP, SAP Analytics Cloud, SAP HANA, and more.
cancel
Showing results for 
Search instead for 
Did you mean: 
Vitaliy-R
Developer Advocate
Developer Advocate
If you have not followed my previous posts, then let me get you up to speed. As a result of previous activities I have a schema TPCDS with 25 tables created and loaded with data generated using TPC-DS simulator. These tables are stored in my trial of SAP HANA Cloud, SAP HANA Database.


In next steps I want to:

  1. build calculation views on top of these tables, and then

  2. build analytic stories using SAP Analytics Cloud.


To avoid repetition and explanation of the workflow, I would suggest you make yourself familiar with:

Here I will rather focus on specifics of the scenario and some additional explanations. So, let's get started!

Create a developer space in the SAP Business Application Studio


I opened the studio from https://account.hanatrial.ondemand.com/trial/#/home/trial and created a new SAP HANA Native Application Dev Space TPCDS. Nothing unusual so far...


Following the workflow (which you might know already from the experience or -- hopefully -- from studying the aforementioned tutorials) let me create the new project by starting from the SAP HANA Database Project template.

My configuration will be the following:







































Property Value
Project Name tpcds
Module name db (default)
Namespace vital.tpcds
Schema Name empty (default)
SAP HANA Database Version HANA Cloud (default)
Bind the database module to a Cloud Foundry service instance? Yes (default)
CloudFoundry binding information Specific for the user (I am using SAP HANA Cloud trial)
Create a new HDI service instance? Yes (default)

And once the wizard configuration has been finalized and the generation step executed we should see a screen like this.




  1. The folder structure and initial files created in the ~/projects/.

  2. A new HDI container (here with the name tpcds-hdidb-ws-x4bb9) created and bound to the project.

  3. The studio is connected to my chosen CF org and space.


Let's open a Studio's Terminal and check the HDI service with the CloudFoundry CLI cf already pre-installed in the Dev Space.
cf service tpcds-hdidb-ws-x4bb9



Utilities and tools


As we saw the cf CLI comes pre-installed in the dev space. So do more commands, like git, curl or mta. But you might want to have some more tools to support your productivity.

In my case, I want to have jq for parsing JSON documents. I placed it in ~/bin/jq. You can find more details on how to do it in this script from my colleague dj.adams.sap, or by following a tip from andrew.lunde on how to install packages without a root user.

Because I am going to work with database objects, I prefer to have SAP HANA Clients in my Dev Space too. This step is optional if you want to do everything using other clients, like Database Explorer's SQL Console, SAP HANA Client installed locally on another machine or DBeaver.

We can install them, the same way as installing them in AWS CloudShell in the previous post Scripting import of multiple files into SAP HANA Cloud.... It is just that this time we need to use preinstalled curl instead of wget.
mkdir -p ~/tmp

curl --junk-session-cookies --output-dir /tmp/ --remote-name \
--header "Cookie: eula_3_1_agreed=tools.hana.ondemand.com/developer-license-3_1.txt" \
"https://tools.hana.ondemand.com/additional/hanaclient-latest-linux-x64.tar.gz"

tar -xvf /tmp/hanaclient-latest-linux-x64.tar.gz -C /tmp/

/tmp/client/hdbinst --batch --hostname=${WORKSPACE_ID}

We should have now SAP HANA Clients installed in the default directory ~/sap/hdbclient/.
Please note the use of the --hostname=${WORKSPACE_ID} flag to avoid issues caused by the fact that our Dev Space is running in the container, and is getting a different hostname every time. ${WORKSPACE_ID} is the environment variable that is the same across sessions.

Add DBAdmin database user to the SAP HANA Clients user store


To add a user to the user store I need my SAP HANA's database endpoint. Yes, we can get it from the SAP Business Technology Platform's UI, but for lazy people like me, it will be fewer clicks to do it from the studio's terminal. We just need to know the name of an SAP HANA Cloud, SAP HANA database service. Or just list it with cf services | grep hana.


So, it is vital-hc-hana in my case. Now let's find its host and port to connect to.
cf service vital-hc-hana


From there I can grab information about the host and the port (and even click on the link to open my database's Cockpit app; how convenient 🙂 )

Ok, it's time to add DBAdmin to the user store in the Dev Space.
~/sap/hdbclient/hdbuserstore -i SET HANACloudTrial_DBAdmin <host-name>:<port-number> DBAdmin

~/sap/hdbclient/hdbuserstore LIST


Now we can check the same SQL as at the beginning of this post using hdbsql and a stored user.
~/sap/hdbclient/hdbsql -U HANACloudTrial_DBAdmin \
-A "SELECT TABLE_NAME, RECORD_COUNT FROM M_TABLES WHERE SCHEMA_NAME='TPCDS';"



Set a version control with Git


The last thing to configure in the Dev Space, for now, is to set the version control using Git. (If you are not familiar with it, then check one of the many online tutorials, e.g. Git Immersion).

You might think that in the trial environment with a single developer (yourself) this might be overkill, but I found it very helpful even for a single person to have versioning to support experimentation. Plus a code repository allows me to move the project from trial to my productive account if needed.

The Dev Space has:

  1. a pre-installed git CLI, as well as

  2. the Git integrated into the Studio, where

  3. Studio's Preferences allow you to configure it.



Throughout my posts, you will find me more often using command line than UI to work with git.

Even before we initiate the git repository, please note that the project wizard has created a file .gitignore already. We will look into the project file structure a bit closer in the next part though.

The one-time setup


Git always requires the first-time setup in the new environment, which in our case is setting a name and the email address of you as a code developer. In my case, it can be something like:
git config --global user.name "Vitaliy"
git config --global user.email sygyzmundovych@example.org

You can verify with git config --list --show-origin that user's name and email have been added to the file /home/user/.gitconfig.

Initialize local Git repository


Let's check we are in the project directory (which is ~/projects/tpcds) and type...
git init

 


...to see what happens.

  1. The directory .git is created in the project folder (but not visible in the Explorer),

  2. But all files in the Explorer (other than listed in aforementioned .gitignore) are marked as U (updated) comparing to the initially empty repository.

  3. These files can be seen from the Git perspective too.

  4. The name of the current branch is displayed in the status bar.


Now we can do the usual stuff to do the initial commit of the code.
git status
git add .
git commit -m "Init commit"
git branch -m "main"
git log


Let's check once again what happened.

  1. After executing the code

  2. The work directory is clean and there are no marks next to files in the Explorer.

  3. The Timeline shows the history of commits for a file opened in the editor (in this example .gitignore)

  4. The branch name is changed to main.


Additional git configuration


And just the last step I would like to add my git command-line configuration is...
git config --global alias.hist "log --pretty=format:'%h %ad | %s%d <-by %an' --graph --date=iso"

...which allows me to run a command like git hist now.


Ok, we are all set with SAP Business Application Studio and our project to start working with them!




Till next post then!
-Vitaliy aka @Sygyzmundovych