After completing this lesson, you will be able to:
After completing this lesson, you will be able to:
Create a database table
Generate the RAP Objects for an OData UI service
Creating The Data Model
Example Data Model
The data model in this example is very simple - there is a single database table that contains details of flight connections - an airline, flight number, details of the departure airport and the destination.
Note
Not included in the figure are additional fields that the RAP runtime needs in order to manage concurrency control. We will look at these a little later on.
In this series of exercises, you will create a Fiori Elements app for managing flight connections. The first step is to create the database table that will store the data.
Steps
Create a new database table called Z##ACONN.
Choose File → New → Other.
In the Filter field, enter Database. The system filters the list of object types so that only object types containing the word Database are displayed.
Double-click Database Table.
Ensure that the correct package (ZS4D400_##) is set. Enter the name Z##ACONN and a description for your table (suggestion: Group ## Active Connections). Choose Next.
Select your own transport request and choose Finish.
Enter the following list of fields between the curly brackets:
For the field city_from, replace the data element /dmo/city with your own data element z##_city_from. For the city_to field, replace the data element /dmo/city with your own data element z##_city_to.
The definition of the city_from and city_to fields should now look like the following: city_from : z##_city_from;andcity_to : z##_city_to;.
Activate the table.
Choose Ctrl + F3.
Generating Additional Development Objects
Generating Additional Objects
We have just defined a database table to hold our data, but the app that we are going to create needs more objects than just this table. We can generate these objects using a wizard in ADT.
The generated objects contain all of the information that is necessary to provide a working app with create, read, update, and delete capability. Later on, we will also adjust and extend some of these objects to change the appearance of the user interface and to implement some checks and calculations.
Watch this video to learn how to generate additional objects.
Generate the Development Objects for an OData UI Service
In this exercise you will generate the additional repository objects.
Prerequisites
You must already have created and activated the database table Z##ACONN.
Steps
Start the object generator in ABAP Development Tools. Ensure that the package is set to your own package, enter a description for the generated objects, and set the generator to generate a UI service.
Right-click the table name in the Project Explorer and choose Generate ABAP Repository Objects.
Enter a description in the Description field.
In the Generator field, open the dropdown list box and select ABAP RESTful Application Programming Model: UI Service.
Choose Next.
Name the objects as described in the table:
Object Type
Object Name
Data Definition Name
Z##_R_Connection
Alias Name
Connection
Implementation Class
ZBP_##_CONNECTION
Draft Table Name
Z##DCONN
Service Projection
Z##_C_Connection
Service Definition
Z##_CONNECTION
Service Binding
Z##_UI_Connection_O4
Binding Type
OData V4 - UI
On the left-hand side of the dialog box, click Data Model. In the right-hand pane, enter the Data Definition NameZ##_R_Connection and Alias NameConnection.
On the left-hand side of the dialog box, click Behavior. In the right-hand pane, enter the Implementation ClassZBP_##_CONNECTION and the Draft Table NameZ##DCONN.
On the left-hand side of the dialog box, click Service Projection. In the right-hand pane, enter the NameZ##_C_Connection.
On the left-hand side of the dialog box, click Service Definition. In the right-hand pane, enter the NameZ##_CONNECTION.
On the left-hand side of the dialog box, click Service Binding. In the right-hand pane, enter the NameZ##_UI_Connection_O4 and select the Binding TypeOData V4 - UI.
Generate the objects.
Choose Next.
Select the appropriate transport request and choose Finish.
Previewing the OData UI Service
Publish and Preview the Service
Using your database table and the object generator, you can generate all of the objects that you need to get a working Fiori Elements app. The only manual step is to publish the service.
You must publish the service before you can test the app. To do so, open the service binding and choose Publish. Once you have done this, the entity that you created (in this case, Connection) appears in the list of entities. Mark it and choose Preview to test the app.
Test the App
When you choose Preview, a browser window opens and you can create a new flight connection. However, the app does not implement any checks other than type checks (for example, only digits are allowed in the Flight Number field).