We all SAP developers know that SAP Cloud Application Programming Model is rocking these days for developing enterprise grade services and applications. In order to develop the CAPM application, we can choose either Node.js or Java as a language of choice and SAP Business Application Studio (BAS), Visual Studio (VS) Code, or Eclipse as an IDE of choice. SAP Business Application Studio is a Web-based IDE that is preconfigured and ready to start development with no additional configuration tasks whereas VS Code and Eclipse require additional tools to be installed for CAPM Development.
In this blog, we will see how to set up VS Code for the SAP CAPM development on the Windows platform. The requirement of tools for CAPM on other operating systems like Mac OS, Linux might be the same but the process of installation of tools is different.
Setting up the VS Code for CAP Node.js Development
First thing first, install Visual Studio Code on your local machine if you haven’t already got one. Once you have a successful installation of VS Code, perform the following steps to make VS Code ready for CAP Node.js development. You can skip any step if you already have that tool installed on your machine.
1. Install Node.js
- Download the latest version of Node.js and follow the installer prompts to install it on your machine.
- To verify the installation of Node.js, run command node -v in Command Prompt. It should print the Node.js version. Also, run command npm -v to ensure npm (package manager) is up and running.
2. Install CDS Tools for CAP Development
- Open Command Prompt and run command – npm i -g @sap/cds-dk
- To verify, run command cds -v in Command Prompt. It should print out installed packages and their versions.
3. Install CF CLI (Command Line Interface) for Cloud Foundry operations such as app deployment, service creation, etc.
- To download the CF CLI installer, visit GitHub repository https://github.com/cloudfoundry/cli
- Go to the README file and then find the Downloads section.
- Select the installation version that you would like to install.
- Download the CF CLI installer for your OS and start installation on your machine.
- After installation, run command cf -v for verification. Please note that You would need to reopen Command Prompt window if it was already open at the time of installation.
- Now install multi apps plugin to enable deployments by running command cf install-plugin multiapps. To verify, run command cf deploy –help. It should print out all the options and usage available for cf deploy command. Refer to SAP Developers Tutorial for installation guide if it didn’t work for you.
4. Install MTA Build Tool (MBT) to build/package a deployment-ready multitarget application
- To install MTA build tool globally, run command npm install -g mbt
- To verify installation, run command mbt -v and it should print out the version info.
- MBT tool requires GNU Make during the build of an application. Ensure you have GNU Make installed on your machine. (If you have Chocolatey installed on your machine, simply run choco install make to install GNU Make)
5. Install Windows Build Tools
- Open Windows PowerShell with the administrator rights and run command npm install –global –production windows-build-tools
6. Required VS Code Extensions
- Python Extension Pack – Required when running the npm install command on the project modules.
- CDS Language Support Plug-in – Required for CDS development e.g. syntax highlighting, code completion, etc.
- XML Tools or any XML Editor extension to work with XML files.
Setting up the VS Code for CAP Java Development
In order to set up the VS Code for CAP Java Development, we will need to perform all the tasks mentioned above for the Node.js development environment including the extensions installation part. In addition to those, the installation of Java JDK and Maven is required. To install Java and Maven, follow the steps given below:
1. Install Java JDK
- Download and install Java JDK 8 or higher if you already haven’t got it installed on your machine.
2. Set JAVA_HOME environment variable
- Open Command Prompt with Administrator rights.
- Run command – setx JAVA_HOME -m “C:\Program Files\Java\jdk1.8.0_251”. Please change the Java path in quotes as per your Java folder location.
- Now run command – setx -m PATH “%PATH%;%JAVA_HOME%\bin”
- To ensure Java Path has set correctly, run command echo %JAVA_HOME% and it should print the Java installation path if it is set correctly.
3. Install Maven
- Download the maven package from the maven website. Unzip the downloaded package using any archive extraction tool like 7-Zip etc.
- Now you can move the extracted folder to your desired location e.g. “C:\Program Files”
4. Set MAVEN_HOME Environment Variables
- Open Command Prompt with Administrator rights.
- Run command – setx -m MAVEN_HOME “C:\Program Files\apache-maven-3.6.3”. Please change the maven path in quotes as per your maven folder location.
- Now run command – setx -m PATH “%PATH%;%MAVEN_HOME%\bin”
- To verify, close and reopen Command Prompt, and then run command mvn -v. It should print out the maven version.
5. Required VS Code Extensions for CAP Java
Don’t forget to also install extensions mentioned in Step 5 of Node.js environment setup.
- Lombok – Required for Java annotation support. It is a must-have extension if you are working with SAP Java Cloud SDK Virtual Data Model (VDM).
- Java Extension Pack – Required for Java Development. Language Support for Java extension is part of this pack and it may not work with Java 8 as it requires Java 11 or higher. If you wish to use Java 8, you may need to downgrade the version of Language Support for Java to 0.64.0.
- Remote Development Extension Pack – Required for SSH/Remote Debugging.
Common Issues that you may encounter for the first time
The Python issue – If you face python error during npm install
- Ensure you have installed Windows build tools. If not, run command npm install –global –production windows-build-tools for installation in Windows PowerShell with administrator rights.
- Install Python Extension Pack in VS Code
- If still error persists, install openssl on your machine and repeat the above steps of this section.
EINTEGRITY Issue during npm install or deployment
Missing SAP CommonCryptoLib
This issue generally appears during deployment of Hana artifacts using ‘cds deploy –to hana’ command. To fix this issue, you will need to have SAP CommonCryptoLib on your machine. A link will be given above the error on the terminal which you can click and follow the instructions to install SAP CommonCryptoLib. Don’t forget to restart windows after finishing the installation.
[ERROR] [cds.deploy] – Services not found
Tips to resolve this issue:
- First, ensure you are logged into Cloud Foundry. If not, log in to Cloud Foundry (cf login) and try again.
- If the issue persists, check which version of CF CLI is installed on your machine. If you installed CF CLI version V7, try uninstalling it and installing V6 instead. As part of my research, people reported issues for CF CLI version V7. Those issues might have been resolved by the time you are reading this blog.