Skip to main content
SAP BTP

Deploying a Cloud Application Programming Project with VS Code vs. BAS

Navaneetha Nalamada Navaneetha Nalamada, Principal Developer 4 min read

Deploying a CAPM Application through the SAP Business Application Studio (BAS) and VS Code is a very simple process if you follow all the steps carefully. In my previous blog, I took you through the creation of a CAPM project through VS Code and BAS. Similarly, in continuation of the series, I will talk about the deployment process and how to push the code to the repository (deploying a cloud application programming project with VS Code vs. BAS). Firstly, let’s see how you would deploy the application into the HANA database through BAS. Initially, start with the following commands in BAS:

  1. Firstly, cds add hana–> (This configures deployment for SAP HANA to use the hdbtable and hdbview formats)
  2. Secondly, cf login —> (here, you will need to login to the cloud foundry with your credentials)
  3. Finally, cf create-service hana hdi-shared (Project name-db) —> (This, creates the service in CF)
  4. cf services (we can now check whether the services have been created or not)
  5. cds build –production → build the application (after the successful build, the project structure gen-folder will be created)
  6. cf push -f gen/db—> (this pushes the db-folder into cloud-foundry)
  7. cf push -f gen/srv –random-route —> (this pushes the SRV-folder into cloud-foundry)

Below, is an example of an application deployed on SAP HANA Cloud;

SAP BTP cockpit Routes page for the dev space listing booksshop-srv and CAPTest-srv routes on cfapps.us10

Now, let’s look at how we can deploy the application into the HANA Database through BAS:

For example, here, we have 2 deployment options through BAS

1) With MTAR

When we create CAPM Project through a template, it will have all the dependency files:

Upon the project’s creation, you will need to follow the steps listed below;

Step 1:

Use command ‘Mbt build’

Then it will generate the mta_archives folder like below

BAS file explorer with the mta_archives folder expanded, showing the TestBAS_1.0.0.mtar file selected

Upon generating the MTAR file, right-click on it and select the ‘Deploy MTA Archive’ option from the menu. Now, enter the CF details to deploy the MTAR file to the CF.

Right-click menu on the .mtar file in BAS with the Deploy MTA Archive option highlighted

Cloud Foundry routes table showing the deployed TestBAS-srv application route

2) Without MTAR

Now, let us see how it would work without generating the MTAR

For this, you would need to use the following command in BAS;

  1. Firstly, cds add hana–> (This configures deployment for SAP HANA to use the hdbtable and hdbview formats)
  2. Secondly, cf login —> (Need to log in the cloud Foundry)
  3. cf create-service hana hdi-shared (Project name-DB) —> (Creating the service in CF)
  4. cf services
  5. cds build –production → Build the application (after the successful build, in project structure gen-folder will be created)
  6. cf push -f gen/db —> (pushing the db-folder into cloud-foundry)
  7. cf push -f gen/srv –random-route —> (pushing the SRV-folder into cloud-foundry)

The Application would be deployed in SAP HANA Cloud in the following manner;

Cloud Foundry routes table showing the deployed MYCAPAPP-srv application route

A) If you needed to push code to GIT through BAS, you would need to;

  1. Create the GIT repository
  2. Open BAS home page click on view — > Find command

Business Application Studio View menu open with Find Command highlighted

  1. Find out the GIT clone.

BAS command palette with git clone typed and the Git: Clone command highlighted

Then you can enter the GIT repository url and click on enter so the clone is completed.

Now, let’s create a project like cds within it.

BAS terminal output of a git push to a GitHub test-CAPM repository, next to the project tree

Upon the project’s creation, save all files. Enter the command ‘GIT push’ to push the code out.

At this point, it should look like the example below:

GitHub repository file list with .vscode, db, .cdsrc.json, .gitignore, README.md and package.json

B) Now let us take a look at how to push code to GIT through VS Code

  1. Create a repository
  2. As a result, you can then login to the GIT account via VS Code:

Upon completing the GIT account login, we follow the same steps as we did to push the code to GIT through the BAS module.

Personally, I prefer working on BAS. In my experience, BAS is a far simpler tool. For example, its in-built libraries make it particularly user-friendly. Further, VS Code regrettably doesn’t offer this feature.

View our other content, here.

Follow our journey on LinkedIn, here.

Share