Modelling in SAP HANA Cloud (part 1): setup the project in SAP Business Applicat...
source link: https://blogs.sap.com/2021/04/09/modelling-sap-hana-cloud-01-setup-project-sap-business-application-studio/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
Modelling in SAP HANA Cloud (part 1): setup the project in SAP Business Application Studio
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:
- build a calculation views on top of these tables, and then
- build analytics 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 path you should have known already from experience or from studying 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 Nametpcds
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 generation step executed we should see a screen like this.
- The folder structure and initial files created in the
~/projects/
. - A new HDI container (here with the name
tpcds-hdidb-ws-x4bb9
) created and bound to the project. - 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 passing JSON documents. I placed it in ~/bin/jq
. You can find more details how to do it in this script from my esteemed college DJ Adams.
Because I am going to work with database objects, I prefer to have a 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 less clicks to do it from the studio’s terminal. We just need to know the name of a 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 (nad 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. 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:
- a pre-installed
git
CLI, as well as - the Git integrated into the Studio, where
- 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 require 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 [email protected]
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.
- The directory
.git
is created in the project folder (but not visible in the Explorer), - But all files in the Explorer (other than listed in aforementioned
.gitignore
) are marked asU
(updated) comparing to the initially empty repository. - These files can be seen in the Git perspective too.
- 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.
- After executing the code
- The work directory is clean and there are no marks next to files in the Explorer.
- The Timeline shows the history of commits for a file opened in the editor (in this example
.gitignore
) - 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 command like git hist
now.
Ok, we are all set with SAP Business Application Studio and our project to start development!
Till next post then!
-Vitaliy aka @Sygyzmundovych
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK