Learn how to build an app with the SAP Web IDE template based on your manually created data model
You will learn
In the previous tutorial you created an OData entity model by hand. In this tutorial, you use that OData model in place of a live OData service to build a master-detail app in SAP Web IDE. Once built, you will then run it using the Web IDE mock data server.
The steps in this tutorial assume that you are familiar with the Web IDE menu and template wizard, and have created an OData model in the previous tutorial. If you are not familiar with Web IDE, it is suggested that you complete the following three tutorials first:
When the project is generated, open the SalesOrder project folder, right-click on index.html and select Run > Run with Mock Data.
The app will open (and you will see a Toast notification that it is running with Mock Data). The data shown is generated by the Mock Data server (based on the Property names and types specified in the OData model).
To make the data more realistic, you can create a JSON file with predefined data. Switch back to the SalesOrder project, expand the model folder, right-click on the metadata.xml file and select Edit Mock Data.
The Edit Mock Data window opens where you have the ability to select the collection (SalesOrders or BusinessPartners) then Add or Delete a row of data. You can also Generate Random Data which will create ten of rows of data similar to what you saw when the app was running.
The check box for the Use the data above as my mock data source sets the data in this view as the source for the data when the app is run again.
To get some initial data populated in the table, select the SalesOrders entity set and click the Generate Random Data button. You can scroll right/left to view all of the columns (one for each Property in the data model).
You can edit individual fields by selecting the generated text and entering your values. The most visible fields in the app are CustomerName, TotalSum and Currency, so just changing those will have a big effect on the appearance. To update those fields in your mock data, select the SalesOrders entity set, and scroll right to the column labeled TOTALSUM (DECIMAL), select the cells in the column one at a time and enter your own values.
Repeat this step for the CUSTOMERNAME (STRING) and CURRENCY (STRING) fields.
Select the BusinessPartners Entity set and click the Generate Random Data button to generate data for that collection and click OK. Web IDE will add two files to your SalesOrder/model folder: SalesOrders.json and BusinessPartners.json.
Step 11: Convert between formats for easier editing
If you need to edit a lot of data or if you want to import existing data for prototyping purposes you can convert the JSON files to CSV (or other formats) and edit the data in a spreadsheet program (like Microsoft Excel), then convert it back to JSON. There are a number of websites online that have JSON to CSV and CSV to JSON tools.
To add the data back to your project, you can simply open and replace the content of the JSON files in your project.