9

Create a CAPM Application using SAP Business application studio for file-based p...

 1 year ago
source link: https://blogs.sap.com/2023/03/08/create-a-capm-application-using-sap-business-application-studio-for-file-based-persistence./
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client
March 8, 2023 3 minute read

Create a CAPM 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 CAPM application developed in SAP Business Application Studio.

SAP CAPM (Cloud Application Programming Model) is a framework on Cloud Foundry environment provided for boiling 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 –

CAPM-Model-1.png

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.STARTCAMP-2.png

Crate-project.png

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

NPM-install.png

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.

Run-Configuration-1.png

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.

pROJECT.png
pROJECT-1.png

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

namespace Dealer;

using
{
    Currency,
    managed,
    sap,
    cuid
}
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 –

Assosiation.png

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

CAT_SERVICE.png

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

SQLite.png

7. Then run the application using the configuration created.

Run-1.png

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.

Output2.png
Output1.png

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.


Recommend

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK