6

Adding Data to the Database Entities on BAS for CAPM Full Stack UI5 Development

 2 years ago
source link: https://blogs.sap.com/2022/04/04/adding-data-to-the-database-entities-on-bas-for-capm-full-stack-ui5-development/
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
April 4, 2022 3 minute read

Adding Data to the Database Entities on BAS for CAPM Full Stack UI5 Development

Welcome to the Fourth Episode of the Series: SAP CAPM Full Stack UI5 Application with CRUD Operations. Till now we have created Development Space in BAS, set up a project structure for development, created entities and exposed the same as Odata services. In this episode, we will be inserting the Data in the created database entity for the project and expose the same.

Assumption(OR Must Have to Start):

  • You have followed our previous episode where we create entities and exposed the same.

Your project structure should look like the below if you carefully followed all our previous episodes.

33-8.png

Step 1: Creating Data

So let’s create a folder in db folder. Right-click on db folder and select New Folder.

42-1.png

Name your folder as data.

43-1.png

Now create a new file in the created data folder.

44-1.png

Name your file as cap_tutorial-SalesOrders.csv. Here cap_tutorial is the namespace – SalesOrders is our entity. It’s a nomenclature that needs to be followed for mapping the data.

cap_tutorial-SalesOrders.csv

45-1.png

Now, it’s time to create actual data. So, in CAPM we use .csv files to create local data. You can easily create them in Excel or Libre or even in Notepad. For now, you can copy-paste it from below.

customerName,PoNumber,customerNumber,orderDate,soNumber,inquiryNumber,totalOrderItems
Adidas,2000000001,3000000001,2021-06-15T19:34:03Z,500009101,30061111,2
Adidas,2000000002,3000000002,2021-06-15T19:34:03Z,500009102,30061111,3
Rebok,2000000003,3000000003,2021-06-15T19:34:03Z,500009103,30061114,2
Adidas,2000000004,3000000004,2021-06-15T19:34:03Z,500009104,30061111,1
Rebok,2000000005,3000000005,2021-06-15T19:34:03Z,500009105,30061113,2
Puma,2000000006,3000000006,021-08-15T15:00:03Z,500009106,30061112,3
Puma,2000000007,3000000007,2021-08-15T15:00:03Z,500009107,30061112,1
Adidas,2000000008,3000000008,2021-08-15T15:00:03Z,500009108,30061115,2

46-1.png

Your final Project Structure should look something like this :

47-1.png

Step 2: Exposing the Data

First let’s save everything and then we will proceed.

48-1.png

We will have to do a cds build.

49-1.png

Now let’s do cds watch, this time when we navigate to the Entity SalesOrders. We will be able to see the added data.

50-1.png

Now you can click on Fiori preview.

38-3.png

You will see the below screen, with No Data. No need to worry, just click on Setting Icon.

51-1.png

Choose all the columns for which you want to see the data and click OK.

52-1.png

We can see the Data is populated now in our fiori preview.

53-1.png

Fiori Preview is a fully you can get a feel of the final Integration here. Like we can also use the Filter Feature.

54-1.png

Feel free to drop your comments in the comment section.

In this blog post we have learnt how to set up a dev-space in Business Application Studio(BAS).

In the next blog post we will see how to set up a project for CAP Development in BAS.

Further reading – https://cap.cloud.sap/docs/guides/

Next Episode: Setting up a UI5 Application on BAS for CAPM Full Stack UI5 Development.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK