In the previous unit, we enhanced the flight model with external data. In this unit, we will preview the OData UI service.
In our development flow, the preview of UI service is the last step.
The value help that is used when creating new travel data will now return agencies that are
retrieved from the remote system ES5
.
In order to be able to distinguish the data that was read from the local table, the remote OData
service changes the description of the agencies,so ES5
is added, and the agencies will have different numbers.
We now have to change the service definition and we will then use the preview to check the changes we have used to extend the app.
You can watch unit 6 of week 5: Creating and Previewing the OData UI Service on the openSAP.com platform.
Hints and Tips
Speed up the typing by making use of the Code Completion feature (shortcut Ctrl+Space) and the prepared code snippets provided. You can easily open an object with the shortcut Ctrl+Shift+A, format your source code using the Pretty Printer feature Ctrl+1 and toggle the fullscreen of the editor using the shortcut Ctrl+M.Please note that the placeholder
####
used in object names in the exercise description must be replaced with the suffix of your choice during the exercises. The suffix can contain a maximum of 4 characters (numbers and letters). Numbers and letters are allowed.
The screenshots in this document have been taken with the suffix 1234. Please note that the ADT dialogs and views may change in the future due to software updates - i.e. new and/or optimized features.
Follow the instructions below.
-
Expand your package ZRAP_TRAVEL_#### > Business Services > Service Bindings
- Open the service binding
ZUI_RAP_TRAVEL_O2_####
- Open the service binding
-
Search the custom entity zce_rap_agency_#### in the list of entity sets and associations.
When we take a closer look at the service binding, we see that the custom entity is listed in the list of entity sets and associations. The custom entity has been automatically added to the list of entities since it is used as a value help in the projection view. However, it is listed with its technical name, so we are going to change this now by adding the custom entity to the service definition.
-
Open the service definition
-
Change the expose statement so that no longer the cds view /DMO/I_Agency is exposed as Travel but the custom entity zce_rap_agency_####.
- Replace the existing expose statement
expose /DMO/I_Agency as Agency;
with the following expose statementexpose zce_rap_agency_#### as Agency;
Please note that it is not possible to add comments to the source code of your service definition. It is hence not possible to comment out the existing statement
expose /DMO/I_Agency as Agency
. It has to be deleted instead and must then be replaced with the code snippet metioned above. - Replace the existing expose statement
-
Activate your changes
-
Navigate back to the service binding
ZUI_RAP_TRAVEL_O2_####
-
Use Refresh from the context menu to update the list of entity sets
-
Double-click on the entity
Agency
-
You will notice that no colums are shown because no UI annotations have been added to the custom entity. Use the gear icon to select all columns.
- Click on the gear icon
- Click on the check box Select All
- Press OK
-
Press Go
This will retrieve a list of agencies from the remote system indicated by the different agency numbers and by having "ES5" added to their name
-
Create a break-point in the method
validateAgency
in the class -
Navigate back to the service binding and double-click on the entity set Travel to start the Fiori Elements preview
-
Create a new travel entity
- When you use the value help you will see that the agency data is retrieved via the custom entity
- When you add a break-point in the validation you will notice that the validation is called three times if draft is used and two times without draft.
In this unit you have learned how to adapt the service definition and that these changes are becoming active immediately in the published service binding.
Find the source code for the updated service definition in the week5/sources folder: Sources or use the following link.
Do not forget to replace all the occurrences of #### with your chosen suffix in the copied source code.