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:
The first step is to download the m104metadata_nav.edmx file you created in the previous tutorial. Open Web IDE in Google Chrome and expand the Metadata folder.
Right-click on the m104metadata_nav.edmx file and select Export. This will download the file to your browser’s default Downloads directory.
In Web IDE, select the File menu and then New > Project from Template.
On the Template Selection page, click on the Category pulldown menu (where you see Featured) and select SAPUI5 Mobile Application.
When the mobile templates are displayed, select the SAPUI5 Master Detail Kapsel Application template, then click Next.
On the Basic Information screen, enter SalesOrder for the Project Name and click Next.
On the Data Connection screen, under Sources select File System. Then click the Browse… button and navigate to the m104metadata_nav.edmx file you downloaded, click Open, then click Next.
Fill in the Template Customization screen fields with the information below, and complete the template wizard.
Search for Customer Name
Enter Customer Name
Main Data Fields
Sales Order Details
Additional Attribute 1
Additional Attribute 2
Navigation Attribute 1
Navigation Attribute 2
Navigation Attribute 3
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.
Run your app again (with mock data) and you will see your updated fields displayed.
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.