SAP CAP Blog Posts
cancel
Showing results for 
Search instead for 
Did you mean: 
kiranmaiJ
Newcomer
385

This end-to-end tutorial helps you set up your SAP BTP Trial and build a full-stack application using:

  • SAP CAP (Cloud Application Programming Model)

  • SAP HANA Cloud
  • SAP Business Application Studio (BAS)
  • SAP Fiori Elements
  • Cloud Foundry Deployment
  • Approuter + XSUAA Authentication

This guide is ideal for students, beginners, and consultants who want to understand how real full-stack applications are built on SAP BTP.

Creating a SAP BTP Trial Account

Access SAP BTP Cockpit

Go to: https://account.hana.ondemand.com/

Click Create Account → This creates:

  • A Global Account

  • A Default Subaccount
  • Access to BTP Cockpit services like BAS, HANA Cloud, etc.

     

    kiranmaiJ_0-1764927492001.png

Understanding Global Account, Directories & Subaccounts

Global Account:

This is the root-level account that contains all subaccounts, users, quotas, and entitlements.

Directories

Directories help organize subaccounts logically such as:

  • Development

  • Testing
  • Production

How to create:
Account Explorer → Create → Directory

kiranmaiJ_1-1764927539831.png

Subaccount

A Subaccount is where the actual development happens. We can:

  • Enable services

  • Deploy applications
  • Create destinations
  • Manage entitlements
  • Select region + environment

Steps:
Account Explorer → Create → Subaccount

kiranmaiJ_0-1764928017496.png

Entitlements:

Entitlements are your service quotas — they define which services your subaccount can use (e.g., HANA Cloud, XSUAA, Destinations).

You can always allocate or modify entitlements for each subaccount.

kiranmaiJ_1-1764928048354.png

Boosters — Automated Guided Configuration

Boosters help you set up complex scenarios with just a few clicks, such as:

  • SAP HANA Cloud

  • SAP Build Apps
  • SAP Build Process Automation
  • CAP + Fiori Full-stack setup

Navigate to:
Boosters → Start

kiranmaiJ_2-1764928261145.png

kiranmaiJ_3-1764928268347.png

Cloud Foundry: Spaces & Instances

Space

A space is a workspace inside Cloud Foundry used for:

  • Deploying apps

  • Managing services

 Instance

An instance is a running version of a service like:

  • Destination

  • XSUAA
  • HANA Cloud
  • HTML5 Apps Repository

 

kiranmaiJ_4-1764928362440.png

Setting Up SAP HANA Cloud

Go to:
Subaccount → Services → Instances & Subscriptions
Select SAP HANA Cloud

kiranmaiJ_5-1764928394907.png

If you face a permission error → assign the user:

In the left-hand panel, go to Security > Users

 SAP HANA Cloud Administrator role collection
Subaccount Admin

kiranmaiJ_6-1764928411703.png

Mapping HANA Instance to Cloud Foundry

Mapping allows CAP HDI containers to deploy artifacts to HANA Cloud.

Instance → Actions → Manage Configuration
Click Sign in to Cloud Foundry → Add Mapping → Review → Save

kiranmaiJ_7-1764928441286.png

kiranmaiJ_8-1764928446024.png

kiranmaiJ_9-1764928452196.png

kiranmaiJ_10-1764928465041.png

Setting Up SAP Business Application Studio (BAS)

Create a Dev Space

Open BAS → Create Dev Space:

Full-Stack Cloud Application

kiranmaiJ_11-1764928530228.png

Enable:

  • Workflow module
  • SAP HANA Tools
  • SAP HANA Performance Tools

Open the Dev Space once it turns RUNNING.

kiranmaiJ_12-1764928576994.png

Building a CAP Project

Project Steps:

  • Open the workspace

  • Update mta.yaml file → Change database path ‘gen/db’ to ‘db’
  • Update package.json →Replace existing CDS code -
"cds": {
    "build": {
      "tasks": [
        {
          "for": "hana",
          "dest": "../db"
        },
        {
          "for": "node-cf"
        }
      ]
    },
    "requires": {
      "db": {
        "kind": "hana-cloud"
      }
    }
  • Install dependencies:
npm install
  • To get Additional files in db folder
npm install -g hana-cli
hana-cli createModule

Add CDS files - Right click on db folder - 

  • /db/e_learning.cds
namespace app.e_learning;
using { Language, managed } from '@sap/cds/common';

type string50 : String(50);

entity Categories {
    key id          : UUID;
    name            : string50;
    description     : String(100);
    Courses         : Association to many Courses on Courses.category=$self;
}

entity Courses : managed {
    key course_id   : UUID;
    course_name     : string50;
    price           : String(100);
    Language        : Language;
    category        : Association to Categories;
}
  • /srv/eLearning_srv.cds 
using app.e_learning from '../db/e_learning';

service eLearning {
  entity Categories as projection on e_learning.Categories;
  entity Courses as projection on e_learning.Courses;
}

Build Project

cds build

Deploying to SAP HANA Cloud

  • Go to DB module → Deploy

  • Open HDI container → load data

kiranmaiJ_0-1764929357934.png

kiranmaiJ_1-1764929370699.png

kiranmaiJ_2-1764929387412.png

kiranmaiJ_3-1764929401384.png

kiranmaiJ_4-1764929412102.png

kiranmaiJ_5-1764929422862.png

  • Import using SAP HANA Database Explorer

kiranmaiJ_6-1764929441070.png

kiranmaiJ_7-1764929475512.png

kiranmaiJ_8-1764929489004.png

kiranmaiJ_9-1764929502271.png

kiranmaiJ_10-1764929513597.png

kiranmaiJ_11-1764929520312.png

Now, right click on table and click on Open Data

kiranmaiJ_12-1764929534406.png

Running the App Locally

cds bind -2 e_Learning-db:SharedDevKey
npm install
cds watch --profile hybrid

Deployment to Cloud Foundry

mbt build

Deploy

cf deploy mta_archives/e_Learning_1.0.0.mtar

Adding Approuter + XSUAA for Authentication

Approuter

Provides a single entry point for your application and handles routing & authentication.

Create using BAS:
Right-click → Create MTA Module from Template → Approuter

kiranmaiJ_0-1764930201622.png

kiranmaiJ_1-1764930214586.png

kiranmaiJ_2-1764930256450.png

XSUAA

Authentication is different from authorization

Authentication - Ensures the user is valid and can access the system.

Authorization - Checks the scopes/roles

Adds OAuth2.0-based authentication & authorization.

cds add xsuaa
npm install

This generates:

  • xs-security.json
  • Required scopes/roles

Generating a Fiori Application:

Using templates:
Right-click → Create MTA Module from Template → SAP Fiori App

kiranmaiJ_3-1764930381393.png

kiranmaiJ_4-1764930388220.png

kiranmaiJ_5-1764930407451.png

kiranmaiJ_6-1764930444981.png

kiranmaiJ_7-1764930463793.png

Run: 

cds watch

kiranmaiJ_13-1764929672463.png

 

kiranmaiJ_8-1764930528097.png