Skip to Content
0 %
Explore the Generated App and OData Service
// Explore More Tutorials

Explore the Generated App and OData Service


Build, run and examine the generated application to understand the OData service in detail.

You will learn

  • How to build and run the application generated in the last tutorial
  • Details about the OData service so you can extend the application in later tutorials

Step 1: Build and run the generated application

Click the Run button to build and run the generated application:

Build and run

The Simulator app now launches. If you have configured the app to allow for push notifications, you will get the following alert dialogue:

Build and run

Press Allow. You now see the initial view:

Build and run

The application name is shown, with a description. You have the option to show a demo version of the application (this should be implemented by hand, as this is not generated by the iOS Assistant) or run the actual, live application.

In this tutorial, you use the live application. Tap the blue Start button to proceed.

The OAuth login screen of SAP Cloud Platform Mobile Services is shown. Enter your login credentials for the SAP Cloud Platform and tap the Log On button:

Build and run

The app now displays the initial Data Privacy acknowledgement page. Tap Allow to proceed.

Build and run

The app now proceeds with a 3-step process. First, you will see the Data Privacy detail page. Tap Next to proceed to the next step.

Build and run

Next you will see the Security detail page. Tap Next to proceed to the next step.

Build and run

Lastly you are presented the Consent detail page. Tap Allow to proceed.

Build and run

Choose a passcode to finish the onboarding process. Tap Next and confirm your passcode.

Build and run

After you confirmed your passcode by tapping the Done button, the application starts with an overview of the available Collections of the OData service:

Build and run
Log on to answer question
Step 2: Examine the generated application

If you tap on the Packages collection, you navigate to a Master list with all available Package entities:

Master screen

If you tap on one of the Package entities, you navigate to a Detail page which lists all the properties for the selected entity:

Detail screen

Notice the DeliveryStatus entry at the 5th row. If you tap on this, it will show the related DeliveryStatus entities for the current Package, based on the association in the OData service:

Detail screen

The OData service structure, and how the two entities are related, are explained in the next step.

Log on to answer question
Step 3: Introduction to the SDK's OData API

The generated application demonstrates the OData proxy classes are working, it enables you to browse their properties, and demonstrates push notifications and the various authentication mechanisms.

To examine the OData service’s metadata you have to enable the developer features in Safari first. For that open the Safari browser and click on Safari, then Preferences and click on Advanced. In the Advanced tab you can enable the Show Develop menu in the menu bar to enable the developer features. The Develop menu will now be visible in Safari. If you click on Develop, choose Show Web Inspector to display raw XML in Safari.

Note: We provided you the XML below so you don’t have to do this necessarily.

Examine the OData service’s metadata, which can be accessed via$metadata

<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<edmx:Edmx Version="1.0" xmlns:edmx="">
  <edmx:DataServices m:DataServiceVersion="2.0" xmlns:m="">
    <Schema Namespace="" xmlns="" xmlns:d="" xmlns:m="">
      <EntityType Name="DeliveryStatusType">
          <PropertyRef Name="DeliveryStatusID"/>
        <Property MaxLength="36" Name="DeliveryStatusID" Nullable="false" Type="Edm.String"/>
        <Property MaxLength="36" Name="PackageID" Type="Edm.String"/>
        <Property MaxLength="256" Name="Location" Type="Edm.String"/>
        <Property Name="DeliveryTimestamp" Type="Edm.DateTime"/>
        <Property MaxLength="16" Name="StatusType" Type="Edm.String"/>
        <Property Name="Selectable" Type="Edm.Int32"/>
        <Property MaxLength="128" Name="Status" Type="Edm.String"/>
      <EntityType Name="PackagesType">
          <PropertyRef Name="PackageID"/>
        <Property MaxLength="36" Name="PackageID" Nullable="false" Type="Edm.String"/>
        <Property MaxLength="256" Name="Name" Type="Edm.String"/>
        <Property MaxLength="256" Name="Description" Type="Edm.String"/>
        <Property Name="Price" Precision="10" Scale="2" Type="Edm.Decimal"/>
        <NavigationProperty FromRole="PackagesPrincipal" Name="DeliveryStatus" Relationship="" ToRole="DeliveryStatusDependent"/>
      <Association Name="PackageDeliveryStatusType">
        <End Multiplicity="1" Role="PackagesPrincipal" Type=""/>
        <End Multiplicity="*" Role="DeliveryStatusDependent" Type=""/>
          <Principal Role="PackagesPrincipal">
            <PropertyRef Name="PackageID"/>
          <Dependent Role="DeliveryStatusDependent">
            <PropertyRef Name="PackageID"/>
      <EntityContainer Name="DeliveryService" m:IsDefaultEntityContainer="true">
        <EntitySet EntityType="" Name="DeliveryStatus"/>
        <EntitySet EntityType="" Name="Packages"/>
        <AssociationSet Association="" Name="PackageDeliveryStatus">
          <End EntitySet="Packages" Role="PackagesPrincipal"/>
          <End EntitySet="DeliveryStatus" Role="DeliveryStatusDependent"/>

As you can see, it is a fairly simple data model containing two Entity Sets (or tables) called Packages and DeliveryStatus. Each entity (or record) in the set is identified as a PackagesType and DeliveryStatusType, respectively.

There is also an association between PackagesType and DeliveryStatusType, where a single PackagesType can have related DeliveryStatusType’s with a 0..n cardinality.

We will now show for each PackageType its related DeliveryStatusTypes, shown in a timeline in ascending order (newest on top). The timeline is built using SAP Fiori for iOS controls.

Using the SDK’s SAPOData framework, you can create OData queries in a simple way. Instead of executing SQL statements, the SDK provides a ‘fluent interface’ or ‘method chaining’ approach to constructing queries, which makes the code much more readable.

A query to get all DeliveryStatus entities for a particular Package would look something like this:

// Function 1
let query = DataQuery()
// SELECT * FROM DeliveryStatus
// WHERE DeliveryStatus.packageID == <selected package ID>

The result of this query is an array of DeliveryStatusType objects.

With OData, you can even have greater flexibility. Since there is a one-to-many association (or ‘Navigation Link’) between Package and DeliveryStatus, you could also load the Package object and all related child DeliveryStatus entities at once:

// Function 2
let query = DataQuery()
// SELECT * FROM Packages
// WHERE <primary key> = <selected package ID>
  .withKey(PackagesType.key(packageID: currentEntity?.packageID))
// LEFT JOIN DeliveryStatus ON <abstracted, defined in association>

Using the generated OData Proxy classes, you can then simply access the PackagesType related DeliveryStatusType objects:

Proxy class
Which of the two queries shown above gets all `DeliveryStatus` entities for a particular `Package`? Paste the query in below.

Next Steps


  • Development environment: Apple iMac, MacBook or MacBook Pro running Xcode 10 or higher
  • SAP Cloud Platform SDK for iOS: Version 3.0
Back to top