In this example, We will try to create a simple CAPM Project.
We will be following below steps-
- 1. Create a Folder / Directory.
- 2. Create a Project inside the Folder / Directory.
- 3. Create a Service (JS) File and define some api endpoints.
- 4. Create a Service (CDS) File with same name as JS file and declare the api endpoints.
- 5. To Build and generate Build File.
- 6. To Deploy the Built Application.
Step 1 - Create a Folder / Directory
We will create a Folder / Directory and inside the Folder / Directory we will create the Project.
In the terminal create a folder using below comman -
To move inside the Folder / Directory -
Step 2 - Create a Project inside the Folder / Directory
To create capm project -
Move inside the project folder -
Install npm dependencies -
It will create a blank CAPM project having 3 blank folders inside it and 1 eslint configuration file and 1 package.json file.
The app Folder is used to create our UI (Fiori).
The db Folder is used to create our database model.
The srv Folder is used to create our services.
Step 3 - Create a Service File and define api endpoints
In the srv folder, create a file with js extension.
For example - We have created myService.js file.
We will define 2 endpoints welcomeFunction and welcomeSomeOne which will return greeting string.
Refer the below code -
Step 4 - Create a Service (CDS) File with same name as JS file and declare the api endpoints
Refer the below code to declare the API Endpoints in cds file (Note the CDS file and JS file should have same name).
Step 5 - To Build and Generate Build File
Step 6 - To Deploy the Built Application
And it is done !!!