Skip to Content

Create a Data Model and Expose It as a Service

Requires Customer/Partner License
Create a capital expenditures data model and expose it via a service, using the low-code capabilities of SAP Business Application Studio.
You will learn
  • How to create a project from scratch from the Application Development Lobby
  • How to create a data model for your application
  • How to expose the data using a service so that you’ll be able to use it in your apps
  • How to add sample data
  • How to preview the service definition
  • How to view the data before creating apps
raz-kornRaz KornJanuary 24, 2022
Created by
raz-korn
November 14, 2021
Contributors
raz-korn

Prerequisites

  • You have access to your Application Development Lobby.
  • Step 1
    1. Projects are created from the Application Development Lobby. You can access the Lobby using its bookmark (if you saved it) or from the SAP BTP cockpit: Select the subaccount you created using the Set Up SAP Business Application Studio for Low-Code Development tutorial, expand Services, click Instances and Subscriptions, and choose SAP AppGyver.

    2. Within the Application Development Lobby, click Create and select Business Application.

      launch bas lcap
    3. Provide a Project Name, e.g. CapitalExpenditures, and click Create.

      launch bas lcap
    4. Wait for the homepage of SAP Business Application Studio for low-code development to load.

      Wait for the “We have finished installing all tools and templates for you, enjoy your work!” notification.

      Loading SAP Business Application Studio for low-code development may take some time, especially if it’s the first time in a day.

      bas lcap loaded

      Close the notification icon at the bottom of the screen (optional).

  • Step 2
    1. From the homepage, click the + of the Data Model tile to add a data model to your project.

      bas lcap open entity editor
    2. Provide an Entity Name for the entity e.g. Capex, and choose Create.

      bas lcap create entity
    3. Click the + to add a property to the Capex entity.

      bas lcap create entity
    4. Select the following:

      Step Parameter Value
      A Property Name description
      B Property Type String (default)
      C Key Property Leave unchecked (default)
      D Null Value Yes (default)
      E Many Leave unchecked (default)
      F Other Facets (Max Length) Leave empty (default)
      bas lcap new property editor
    5. Add the following property (click +), and choose Create.

      Step Parameter Value
      A Property Name total_cost
      B Property Type Integer
      C Key Property Leave unchecked (default)
      D Max Length Leave empty (default)
      E Null Value Yes (default)
      F Many Leave unchecked (default)
      bas lcap new property editor

      The Capex entity appears in the Data Model Editor tab with a default ID property.

      To edit an entity, click the entity’s header and choose the Edit Entity icon.

      bas lcap entity editor
    6. Access the Home tab.

      bas lcap return to home
    7. Click the + of the Data Model tile to add a data model to your project.

      bas lcap open entity editor
    8. Provide an Entity Name for the entity e.g. Contractors.

      bas lcap create entity
    9. Change the Property Name of the ID property to contractor, and its Property Type to Integer.

      bas lcap edit property
    10. Add the following property to the Contractors entity, and choose Create.

      Step Parameter Value
      A Property Name name
      B Property Type String (default)
      C Key Property Leave unchecked (default)
      D Null Value Yes (default)
      E Many Leave unchecked (default)
      F Other Facets (Max Length) Leave empty (default)
      bas lcap add property

      The Contractors entity appears in the Data Model Editor.

  • Step 3
    1. Select the Capex entity, choose the Add Relationship icon, and select the Contractors entity to add a relationship to the Contractors entity.

      bas lcap add relationship
      bas lcap add relationship
    2. Select the following, and choose Create.

      Step Parameter Value
      A Relationship Association (default)
      B Relationship Type To-One (default)
      C Property Name contractor
      D Target Entity Type CapitaExpenditures.Contractors (default)
      E Backlink Property Leave empty (default)
      bas lcap add relationship
    3. You can re-arrange the entities on the canvas manually or by clicking the Auto Layout icon to improve the data model visualization.

      bas lcap add relationship
  • Step 4
    1. Access the Home tab.

      bas lcap return from data model editor to home tab
    2. Click the + of the Service tile to add a service through which data from the data model can be accessed.

      bas lcap launch service editor
    3. Define the following for your new service, and choose Create.

      Step Parameter Value
      A Name Capex
      B Namespace CapitalExpendituresService (default)
      C Type CapitalExpenditures.Capex
      D <all properties> Leave checked (default)
      E ID Leave checked (default)
      F description Leave checked (default)
      G total_cost Leave checked (default)
      H contractor Leave checked (default)
      bas lcap edit service

      The Capex service appears in the Service Editor tab.

    4. Access the Home tab, and define the following new service.

      Step Parameter Value
      A Name Contractors
      B Namespace CapitalExpendituresService (default)
      C Type CapitalExpenditures.Contracotrs
      D <all properties> Leave checked (default)
      E contractor Leave checked (default)
      F name Leave checked (default)
      bas lcap edit service

      The Contractors service is added to the Service Editor, with association to the Capex service.

      bas lcap service editor
    5. Select the Capex service (Which gets highlighted with a blue rectangle indication), and check the Draft Editing property.

      A draft is an interim version of a business entity that has not yet been explicitly saved as an active version. This allows users to be e.g. interrupted, and continue later on. For more information visit SAP Fiori Design Guidelines - Draft Handling.

      bas lcap draft editing
    6. You can re-arrange the entities on the canvas manually or by clicking the Auto Layout icon to improve the service visualization.

      bas lcap service editor auto layout
    7. Access the Home tab. You can see that both the services are added to the Service tile.

      bas lcap service editor auto layout

    When the app is running, how does it access the data?

  • Step 5

    It is a common practice in software development to test run any change to an app as soon as possible. Prior to having the services defined, you were not able to test the app. Since now you have defined the services, you can test them.

    1. Choose the Preview option from the homepage, and select either With Sample Data or With Live Data option.

      bas lcap launch preview
    2. The project preview page appears in a new tab with the links which allow you to test the service definition, access data exposed by the service, and more.

      bas lcap launch preview
    3. Choose the metadata to view the service’s XML.

      bas lcap launch preview
    4. Select the Capex or the Contractors view as code to view the data from the respective service.

      bas lcap launch preview

      Here, the value appears as an empty list since the data model is empty.

  • Step 6

    To test that the service works well, i.e. returns data when it is available in the data model, let’s add sample data to your project. Sample data is a powerful tool as it allows you to (1) develop an app with no connectivity to a data source; (2) Debug your app.

    1. Go back to the browser tab with SAP Business Application Studio for low-code development, and click the + of the Sample Data tile.

      bas lcap launch add sample data
    2. Choose Create, select Contractors, and choose Create.

      bas lcap launch add sample data
    3. In the sample data editor add 4 rows.

      bas lcap edit sample data
    4. Update the sample data as follows:

      bas lcap edit sample data
    5. Access the Home tab, and click the + of the Sample Data tile.

      bas lcap edit sample data
    6. Choose Create, select Capex, and choose Create.

      bas lcap launch add sample data
    7. In the sample data editor add 3 rows, and update the DESCRIPTION and CONTRACTOR columns as follows:

      bas lcap edit sample data
    8. Access the Home tab. You can see that the sample data is added to the Sample Data tile.

      bas lcap sample data
    9. Go back to the project preview browser tab, and click either the link of the Contractors service or the link of the Capex service. You can view the sample data you have added.

      bas lcap view sample data from service
Back to top