Exploring the Architecture of RAP

Objectives
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.

Let's see how to define a database table.

How to Create Data Elements

Steps

  1. Create a new data element called z##_city_from.

    1. Choose FileNewOther.

    2. Type Data e into the filter field. The system reduces the hit list to Data Element.

    3. Double-click Data Element.

    4. Ensure that your package is set to ZS4D400_##. Enter the name Z##_CITY_FROM and a description. Choose Next.

    5. Select your transport request and choose Finish.

  2. Use the domain /dmo/city to specify the type of the data element.

    1. In the Type Name field, enter /dmo/city.

  3. For each of the texts (short, medium, long, heading), enter a suitable text.

    1. Enter Departure in the Short field.

    2. Enter Departure City in the Medium field.

    3. Enter Departure City in the Long field.

    4. Enter Departure in the Heading field.

  4. Activate the data element.

    1. Choose Ctrl + F3.

Create Data Elements

Steps

  1. Create a new data element called z##_city_from.

    1. Choose FileNewOther.

    2. Type Data e into the filter field. The system reduces the hit list to Data Element.

    3. Double-click Data Element.

    4. Ensure that your package is set to ZS4D400_##. Enter the name Z##_CITY_FROM and a description. Choose Next.

    5. Select your transport request and choose Finish.

  2. Use the domain /dmo/city to specify the type of the data element.

    1. In the Type Name field, enter /dmo/city.

  3. For each of the texts (short, medium, long, heading), enter a suitable text to describe the departure city.

    1. Enter Departure in the relevant fields.

  4. Activate the data element.

    1. Choose Ctrl + F3.

  5. Create another data element called Z##_CITY_TO. For the data type, use the domain /dmo/city again. For the field labels, use the word To.

    1. Repeat the exercise from step 1 to 4 using the data element name Z##_CITY_TO and the field label Destination instead of Departure.

How to Create a Database Table

Create a Database Table

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

  1. Create a new database table called Z##ACONN.

    1. Choose FileNewOther.

    2. 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.

    3. Double-click Database Table.

    4. 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.

    5. Select your own transport request and choose Finish.

  2. Enter the following list of fields between the curly brackets:

    Code snippet
    
    key client                : abap.clnt not null;
    key uuid                  : sysuuid_x16 not null;
        carrier_id            : /dmo/carrier_id;
        connection_id         : /dmo/connection_id;
        airport_from_id       : /dmo/airport_from_id;
        city_from             : /dmo/city;
        country_from          : land1;
        airport_to_id         : /dmo/airport_to_id;
        city_to               : /dmo/city;
        country_to            : land1;
        local_created_by      : abp_creation_user;
        local_created_at      : abp_creation_tstmpl;
        local_last_changed_by : abp_locinst_lastchange_user;
        local_last_changed_at : abp_locinst_lastchange_tstmpl;
        last_changed_at       : abp_lastchange_tstmpl;
    
    Copy code
  3. 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.

    1. 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;.

  4. Activate the table.

    1. 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.

How to Generate the 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

  1. 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.

    1. Right-click the table name in the Project Explorer and choose Generate ABAP Repository Objects.

    2. Enter a description in the Description field.

    3. In the Generator field, open the dropdown list box and select ABAP RESTful Application Programming Model: UI Service.

    4. Choose Next.

  2. Name the objects as described in the table:

    Object TypeObject Name
    Data Definition NameZ##_R_Connection
    Alias NameConnection
    Implementation ClassZBP_##_CONNECTION
    Draft Table NameZ##DCONN
    Service ProjectionZ##_C_Connection
    Service DefinitionZ##_CONNECTION
    Service BindingZ##_UI_Connection_O4
    Binding TypeOData V4 - UI
    1. 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.

    2. 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.

    3. On the left-hand side of the dialog box, click Service Projection. In the right-hand pane, enter the NameZ##_C_Connection.

    4. On the left-hand side of the dialog box, click Service Definition. In the right-hand pane, enter the NameZ##_CONNECTION.

    5. 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.

  3. Generate the objects.

    1. Choose Next.

    2. 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).

Log in to track your progress & complete quizzes