Hi All and welcome to this blog.
This blog is concerned about creation and deployment of various modules (namely Hana, Java ,NodeJS) to SAP cloud platform cloud foundry as a single Multi-target Application.
All the modules will be created using SAP Web Ide Full Stack.
We will go through step by step creation and deployment of these modules starting with Hana module and moving up to NodeJs and then Java.
Use Case:- We are going to create an Hana trial database and will create entities in it .
The data inside these entities will be exposed by NodeJs odata layer.
Java layer would be able to insert records in this database using JDBC.
Below described is a macroscopic overview for each module:-
1)Hana Trial database – We will create an instance of SAP HANA Schemas & HDI Containers (Trial) and use this as our underlying database system.We will be creating entities in this database and insert records (persist data).
2)NodeJs module:- We will create a nodeJs module to expose the data present in the above Hana DB as odata service.
3)Java (Springboot):- We will create a simple Springboot app which used JDBC to persist data inside the hana trial instance .
Pre-requisites required :-
Accounts and infrastructure:-
Lets start with creation of the first module HANA :-
STEP 1:- Launch SAP web Ide full Stack and create a new MTA project.
Log into your SAP cloud platform neo trial and start SAP web Ide Full Stack service.
SAP web Ide Full stack service is still a part of NEO rather than Cloud foundry.
So we will be using this service from NEO and will connect it to our SAP cloud foundry trial account (endpoint).
Inside the Web ide, right click on the workspace and create a new Multi target application.
This application is going to have all the modules inside it .
After the successful creation of the MTA, you will see a new project named "JobPortal" in your workspace.This is going to have a default generated mta.yaml manifest file.
With changes(addition and deletion) to the MTA, manifest file will automatically be updated by the webIde.
STEP 2:Create a HANA DB module, cds artifact inside the MTA project.
Right click on the created MTA and create a new hana database module and name is as "DB".
Now we will create a CDS artifact for the DB module and add two entities to it, Job and Enrollment.
Right click on the src folder of the DB module and create a new cds artifact.
After this you can use the graphical view layout to drag and drop and create table,define relation mappings etc in the DB module.
For reference I am pasting here the code for the cdsartifact. I have named the file as cdsArtifact.hdbcds.
STEP 3:- Create and insert some mock data using hdbtabledata files in both the tables.
We need to create jobs.hdbtabledata and enrollments.hdbtabledata fikes in the same src folder of DB module.
The contents of the files are:
As directed by the upper two hdbtabledata files, the data to be inserted will be present in job.csv and enrollments.csv. So we create these csv files having data to be inserted in both the tables in the same folder src.
Finally the whole DB module would look like this in SAP web Ide full stack
Its time to build the DB module. In order to do that , you need to make sure you have a builder installed in your cloud foundry account in SCP.
Right click on the DB module and build it .
You can right click on the src folder and open the HDI container to look at the created tables.
You can also use this to work out other SQL queries(Insert,delete etc) as well.
STEP 4:- Create a nodeJs module in order to expose the above created database as an odata service
Right click on the MTA project and create a new module, NodeJs module.
I am naming this module "odatajs" and enabling support for xsjs.
Now lets create a new folder under lib named "xsodata" which will contain our xsodata file.
After creating the folder , create a "service.xsodata" file and put this code snippet in the file.
Now run this module as nodeJs application. You will get a generated link.
Change the url and add your service file location at the end (see in snapshot).
You will be able to see the data persisted in Hana module.
Step 5:- Create a Java module to persist records in existing DB module(Hana trial db)
Right click on the MTA project and create a new Java module. Select Spring boot .
The structure of the project would look like this.
We will be using Java JDBC and will be pushing some records in Jobs entity.
In the HelloController.java file create a new method called CreateJobs and add this code to it .
Call this method after the connection is established.
I have placed it here:-
After this, build the java module .
After you successfully build it, run the module as Java application.
Click on the URL generated. You will be able to see your Hana database user and schema name along with status of JDBC connectivity.
Along with this you will see the message "Records inserted".
To check the inserted record in the entity, right click and open the HDI container.
Click on tables>> Job table.
Double click and select open data.
You should see your record present.
So now we have built all the three modules as a part of a Multi target application and deployed them on SAP cloud platform cloud foundry.
I hope this information would be helpful.
Comments ,doubts and suggestions are always welcome.，什么大数据，淘客易，云产品，hadoop大数据，物联网教室