Enterprise Resource Planning Blogs by Members
Gain new perspectives and knowledge about enterprise resource planning in blog posts from community members. Share your own comments and ERP insights today!
cancel
Showing results for 
Search instead for 
Did you mean: 
Hamad
Explorer

Introduction:

In the ever-evolving landscape of SAP development, a seamless and efficient local development environment is crucial for developers working on projects involving the Cloud Application Programming Model (CAP). In this blog post, I'll guide you through a quick and hassle-free setup for SAP CAP local development on a Windows machine. I'll utilize popular tools such as Chocolatey, Node.js, Visual Studio Code, and more to ensure a smooth development experience.

Step 1: Open PowerShell as Administrator

  • Press Windows Key + X to open the Power User menu.
  • Select "Windows PowerShell (Admin)" or "Terminal (Admin)" from the list.

Terminal.png

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Step 2: Run the Setup Script

Once the PowerShell window is open, run the following script to set up your SAP CAP local development environment efficiently:

 

 

# Quick way to Setup for SAP CAP Local Development Environment
# 1. Install Node.js
# 2. Install SQLite
# 3. Install cURL
# 4. Install Visual Studio Code
# 5. Cloud Foundry CLI

# Windows + X -Key -> Terminal (Admin) - > Run below scrip =>

# Check if Chocolatey is installed
if (-not (Get-Command choco -ErrorAction SilentlyContinue)) {
    # Install Chocolatey
    Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
}

# Check if Node.js is installed
if (-not (Get-Command node -ErrorAction SilentlyContinue)) {
    choco install nodejs-lts
}

# Check if SQLite is installed
if (-not (Get-Command sqlite3 -ErrorAction SilentlyContinue)) {
    choco install sqlite
}

# Check if cURL is installed
if (-not (Get-Command curl -ErrorAction SilentlyContinue)) {
    choco install curl
}

# Check if Visual Studio Code is installed
if (-not (Get-Command code -ErrorAction SilentlyContinue)) {
    choco install vscode
    choco install -y make jq cloudfoundry-cli
    cf install-plugin multiapps
}

$ExecutionContext.SessionState.LanguageMode
Set-ExecutionPolicy RemoteSigned -Scope Process

Write-Host "All software checks and installations completed for SAP CAP, Thank you | Hamad."

 

Step 3: Run the Setup Script for NPM Packages and Git

Open Command Prompt and run the following commands.

 

rem Open CMD | Command Prompt

rem 1. Install the MTA Node.js package
rem 2. Install Yeoman
rem 3. Install Git
rem 4. Install CAP's sap/cds-dk
rem 5. Install CAP's sap/generator-fiori

echo Install Yeoman
    npm install -g yo
echo Install the MTA Node.js package
    npm install -g mta
echo Check if Git is installed
if (-not (Get-Command git -ErrorAction SilentlyContinue)) {
    winget install --id Git.Git -e --source winget
}
echo Check if @Sap/cds-dk is installed globally
    cd %userprofile%
rem npm set :registry=https://npm.sap.com
    npm config delete "@sap:registry"
    npm config ls
if (-not (Get-Command cds -ErrorAction SilentlyContinue)) {
rem cd %AppData%\npm\node_modules
    npm info @Sap/cds-dk
    npm install --global @Sap/cds-dk
    npm install --global @Sap/cds-dk@1.4.2

echo Install the generator from NPM
    npm install -g /generator-fiori
    npx check-sap-cloud-readiness -codejam-cap
}

 

Step 4: Run Commands to Check Versions

To Check the versions of installed software and Node Global Packages run the following commands on Command prompt.

 

echo Check Versions
node -v
npm -v
sqlite3 --version
curl --version
git version
npm -g list
cds -v
cds

 

Step 5: Create a SAP CAP Project

Now that we have our environment ready, let's create a SAP CAP project named "bookshop."

 

# Create a new directory for your project
mkdir bookshop

# Change into the project directory
cd bookshop

# Initialize a new SAP CAP project
cds init

# Add a Sample Entity Set
cds add tiny-sample

# Run the SAP CAP Project Locally
start http://localhost:4004
cds watch
echo Finally, let's run our SAP CAP project on localhost http://localhost:4004 (Refresh).

 

Step 6: Now Open the Project in VS Code:

Terminal.png

Conclusion:

Congratulations! You've successfully set up your local development environment for SAP CAP on Windows. This streamlined process ensures that essential tools and dependencies are in place, we have created a sample project, added an entity set, and running it on localhost. This sets the stage for building sophisticated SAP applications with ease.

Feel free to explore further customization and functionalities within your SAP CAP project

Hamad

Labels in this area