Skip to Content
Technical Articles
Author's profile photo PALLAB HALDAR

Create a CAP Application using SAP Business application studio for file-based persistence.

In this session we will discuss about the file base persistence of a local file using a simple CAP application developed in SAP Business Application Studio.

SAP CAP (Cloud Application Programming Model) is a framework on Cloud Foundry environment provided for providing service and application which can use to solve different business scenario for enterprise corporation. The Core Data & Services (CDS) to build data models and service definitions  consuming the data from the underlying SQL database like HANA  and exposed as a service to different platform. The are two types of runtime environments in CAPM i.e. Java and Node.JS. The Structure looks like below –


Today We will create a simple CAMP application in which we will upload a CSV file Data. Link with another dataset using Association and expose as a services.

1. Create New Project from Template and Select CAP Project and put the name. Use node.js runtime environment. In our case we put name as TIRE_STORE. Click on Finish.

2. Execute “npm install” from new Terminal. It will installs dependencies from your package.json.

3.Open the Run Configurations window and select Create Configuration. Choose the TIRE Store Created Project and name the run configuration as Run “TIRE_STORE-3” and run it.

4. Create two CSV file which will act as source of two data set. You can upload two CSV file also. While data modeling we will associate with DealerID filed to link this two entity to get the dealer name for a Tire.


5.  Create the data modeling CDS file named “data-model.cds” to link two entity with the below code –

namespace Dealer;

from '@sap/cds/common';

entity TireStore : managed
    key ID : Integer;
    Brand : String(111);
    TireType : String(1111);
    Price : Decimal(9,2);    
    DealerID : Integer;
    tireDealer : Association to one TireDealer;

entity TireDealer : managed
    key DealerID : Integer;
    DealerName : String(111);


Then in the graphical mode check  the association is already created –



7. Create the CDS file which will consume the entities and expose as a service. Name it  –



6. Now we have completed all the modeling part .Now deploy  the project into Node.JS environments using cds deploy –to Sqlite so that data will persists in sqlite.db. After deploy when service exposed. Data will be served to the exposed service  served from the file sqlite.db



7. Then run the application using the configuration created.



8.  Open the service in a new table and you can see the Tire Store and Dealer entries exposed as OData services from the database persistence files in sqlite.db.


Hope this will help. In the next session we will check how to create CDS view from HANA calculation view and exposed as a service.

Assigned Tags

      1 Comment
      You must be Logged on to comment or reply to a post.
      Author's profile photo Mustafa Bensan
      Mustafa Bensan

      Hi Pallab,

      Please note that the acronym for the SAP Cloud Application Programming Model is now CAP and not CAPM.