REFERENCE DOCUMENT: There are mismatches in the artifacts names as shown in videos
and in this document. This document is just for general help.
Access the SAP Business Application Studio
Create a development space in BAS
1. Click on Create Dev Space.
2. As you can see you select form a variety of different preconfigured settings on
the left, depending on your needs. Enter the following details:
i. Dev Space Name: dev_space
ii. Select Full Stack Cloud Application
3. For the Additional SAP Extensions select:
i. SAP HANA Calculation View Editor
ii. SAP HANA Performance Tools
iii. SAP HANA Tools
iv. SAP HANA Smart Data Integration Tools
v. and click on Create Dev Space .This makes it possible to develop without
friction. Extensions can also be added at a later stage.
4. Your Dev Space will be configured in the background. This takes one or two
minutes.
5. Once the Dev Space is ready, its status will change to RUNNING. Now you can
click the name of the space to open it.
Create a SAP Cloud Application Programming Model project
1. Click on Start from Template to create a new project.
2.
i. Select CAP Project.
ii. Click on Start to have the wizard create the project.
3. Please fill in the following information:
i. Enter your project name
ii. Select your runtime: Node.js
iii. Click finish and add features to your project using below cds
commands
cds add mta, & cds add hana
follow video for how to write commands.
Adjust the generated CAP project for SAP HANA Cloud development
1. Click on mta.yaml file in the project tree and adjust the path to path: db
3. Click on the package.json file and delete the entire devDependencies section.
4. Now replace the entire cds section with the following content:
"cds": {
"build": {
"tasks": [
{
"for": "hana",
"dest": "../db"
},
{
"for": "node-cf"
}
]
},
"hana": {
"deploy-format": "hdbtable"
},
"requires": {
"db": {
"kind": "hana"
},
"auth": {
"kind": "dummy-auth"
}
}
}
It should look like this:
Install Dependencies
1. Click on Terminal and then on New Terminal. A new terminal will open in the
bottom of your BAS, allowing you to run different commands.
2. Run the following command
npm install
3. After the first command has finished, enter the following command
npm install -g hana-cli
4. To finish the creation, run the following command
hana-cli createModule
Congratulations! You have done initial configuration.
Chapter 2: Create the database objects
1. Expand the SAP HANA PROJECTS tab by clicking on it and moving it up to the
middle of the screen.
2. Click on the plug icon.
3. Select the first option Bind to the default service instance
4. The creation of the HDI container is now in progress. This will take 1-2 minutes.
5. Once the creation has finished a dialog will automatically open. Please
select Enable.
Bind a user-provided service instance to the project
1. To access sources outside of your HDI container, for example the remote sources
that are created by us, you need to add a user-provided service. Click an the plus
icon to add a User-Provided Service.
2. A new wizard will open up and ask you to fill in the following information:
i. Select connection type: Existing user-provided service instance
ii. Select SAP HANA user-provided service instance name click on Add.
Add some config to the database module
1. Right click on the folder db and click on New File.
2. Fill in cfg/grants.hdbgrants and click on OK.
3. Paste the code in the editor to allow your HDI container to work with the User-Provided
Service.
4. Now click on the rocket icon in the SAP HANA PROJECTS tab to deploy the created
database artifact to HANA.
5.
6. The deployment will end successfully.
SAP HANA Database Explorer
1. Click on the Open HDI container icon in the SAP HANA PROJECTS tab next to the
rocket.
2. Click on Sign in with default identity provider.
3. Check tables and views in database explorer, check the data.
Chapter 3: Create the service module
Create a facade entity
1. We have to expose the PRODUCTS view from the last Chapter to the Cloud Application
Programming model by creating a facade entity in a CDS data model. Create a New
File in the db folder and name it dbartifacts.cds.
2. Now write the code as shown in videos.
Create a service interface
1. Select the "srv" folder (the folder below the root folder) and (not src) create a New
File and name it dbartifacts-srv.cds.
2. Write the code as shown in videos.
Build the CAP Service module
1. Click on Terminal and then on New Terminal to open a new terminal.
2. Now run the command cds build.
3. Deploy all the new created files to SAP HANA Cloud by clicking on the rocket.
Congratulations! You are now ready for chapter four of this exercise!
Chapter 4: Test the service and deploy the full application to SAP
Business Technology Platform
Test the service locally
1. Use the terminal to navigate to the db subfolder, run cd db to do this. Then run hana-cli
copy2DefaultEnv. In order to use the data of the HDI container and the data from
outside for local testing, we need the connection info for the HDI container instance.
These are stored in the file .env in the db folder. With the command we copy them into a
new file called default-env.json on the same folder level.
2. Select the new file default-env.json and drag it to the root folder of the project.
3. Now switch back to the terminal and run cd .. to navigate back to the root
folder.
4. Now run npm start. This command will start the service we have created.
5. Click on the products entity to have a look at the data that is stored on the
database.
Build the application and deploy to SAP BTP
1. Once the local application is working, it is time to deploy this application to the
SAP BTP. Right-click on the mta.yaml file and click on Build MTA Project.
2. Once the build process is complete, a new folder named mta_archives is created
at the top project level. Unfold the folder and right-click on the .mtar file and
then on Deploy MTA Archive. This process will take some time as all the services
and applications that are part of the project will be created from scratch.
3. If the deployment has finished successfully, there is also a link in the log. Copy
this link and open it.
4. Click again on the products entity.