CAP Product Management App with CRUD Operation

In this example, Our goal is to create Product Management CAP Application.

Github link - https://github.com/HimanshuSap124/Product-Management-CAP-App

We will be following below steps-

      1. Creating a CAP App.
      2. Create Schema in db and Add Data.
      3. Create Service cds file and declare the endpoints.
      4. Create Service js file and define the endpoint logic.
      5. Create the utility Files.
      6. Create Test API File.
      7. Deploy on SQLite Server to run the application Locally.
      8. To add Hana, mta file, xsuaa and approuter file.
      9. Define Destination Service configuration and Logger service configuration on mta file.
      10. Update and Lock Package lock file and Build, Deploy the application.

Step 1 - Creating a CAP App

Use the below command to create a CAP Application -

Here, our Application name is warehouse-cap-app

Now, go inside the Project Folder, and install the dependencies. -

Step 2 - Create Schema in db and Add Data

In the Project on db folder we have define Schema.cds file which you can refer.

Step 3 - Create Service cds file and declare the endpoints

In the Project on srv folder we have define custom-service.cds file which you can refer.

In this file, we have declared all the endpoints which we are going to use.

Step 4 - Create Service js file and define the endpoint logic

In the Project on srv folder we have define custom-service.js file which you can refer.

In this file, we have defined the endpoints and simply calling the logic methods from specific utility folder.

Step 5 - Create the utility Files

In the Project on srv folder we have define ProductUtility.js file and OrderUtility.js file on which we have defined the Product CRUD Logics and Order CRUD Logics which you can refer.

Step 6 - Create Test API File.

In the project, I have created Test API Folder inside which I have defined testAPI.http file and defined endpoints to test the application.

Step 7 - Deploy on SQLite Server to run the application Locally

Use the below line of command to deploy it Locally on SQLite DB -

Now run the application using cds watch and test the endpoints using testAPI.http file.

Step 8 - To add Hana, mta file, xsuaa and approuter file

Step 9 - Define Destination Service configuration and Logger service configuration on mta file

In the mta.yml we have defined the Destination service configuration.

(Refer to line 30, 62, and 107 for destination configuration and line 31 , 114 for Logger Service configuration in mta file)

Step 10 - Update and Lock Package lock file and Build, Deploy the application

And it is done, You can deploy your app and use it. !!!