Model Creator for SAP Integrations

Last modified: November 19, 2024

Introduction

Mendix apps can consume OData services exposed by SAP back-end systems. To do this you need to use the OData Connector for SAP Solutions, which needs to know details of the OData service which has been exposed. This involves mapping the data structures exposed by the OData service (via the $metadata URL) to entities and attributes of the domain model. This information is created as a Mendix module (.mpk) file which can be imported into your Mendix app.

SAP data models reflect an OData service or BAPI from SAP back-end systems like SAP Business Suite (SAP ERP 6.0), SAP S/4HANA, and SAP S/4HANA Cloud.

Handcrafting a Mendix domain model for these services would be a lot of work. The Model Creator for SAP Integrations automates this process by creating a Mendix module for the selected service containing the Mendix domain model which can be imported in your app. The data model also contains additional information such as the URL of the exposed endpoint, a list of collections in the service, and a list of functions provided by the service.

For a BAPI service you will need to download a BAPI Schema. See Create a Mendix BAPI Module Using the Model Creator for information on how to use the BAPI Schema.

For an OData service, there are four ways to create the data model:

SAP Data Models

The Data Model module contains up to four resources which help to consume the OData Service:

  • Domain Model
  • Service Root
  • Entity Set Names
  • Function Names

Domain Model

Each Mendix SAP data model has a domain model that describes the information in the OData service. The domain model consists of entities and their relations represented by associations. For more information, see Domain Model.

Service Root

The module contains a constant whose value is the service root of the OData service. For example, the GWSAMPLE_BASIC data model, generated from the SAP Catalog Service using the Model Creator for SAP Integrations has a Service Root which is the constant GWSAMPLE_BASIC which has the value https://sapes5.sapdevcenter.com:443/sap/opu/odata/iwbep/GWSAMPLE_BASIC.

Entity Set Names

The enumeration EntitySetNames contains a list of the collections in the service. These are entities which can be queried to produce a list of matching objects.

Function Names

The enumeration FunctionNames contains a list of functions which are exposed by the OData service. To assist in using these functions the domain model will also include an entity for each function, suffixed with the string Parameters, which is used to provide the required parameters to the function.

Prerequisites

Before starting this how-to, make sure you have completed the following prerequisites:

  • Identify the SAP back-end system and OData service or BAPI you wish to use
  • Create an app in Mendix Studio Pro (version 8.18.10 or above)
  • For a BAPI you will need to download a BAPI Schema – see BAPI Schema for Model Creator in BAPI Connector for SAP Solutions for more information
  • Obtain authentication credentials, if needed, for the SAP Catalog Service or SAP back-end system you wish to use

Generating an OData Data Model

The Model Creator for SAP Integrations is an app in the Marketplace. Search for it in the Mendix Marketplace, or find it here: Model Creator for SAP Integrations - OData. If the app gives you a choice between SAP OData and SAP BAPI, choose SAP OData.

Open the Model Creator for SAP Integrations - OData, where you will be asked how you want to generate your model:

There are four ways to generate your data model.

Using the API Business Hub

Your SAP back end OData API is held in the API Business Hub.

  1. Click API Business Hub.

    You will be presented with a list of packages containing OData API definitions. You can search this list (this includes text in the package description as well as the package name), and page through it using the paging buttons.

  2. Click the package you want. It will be highlighted.

  3. Click Next to see the APIs within the package.

  4. Click the API you want. It will be highlighted.

  5. Click Next to see the schemas within the API.

  6. Click the schema you want. It will be highlighted.

  7. Click Next to proceed to the confirmation screen.

  8. Click Generate .mpk to generate the data model module.

  9. Click Download.

    Your browser will offer options on what to do with the file.

  10. Save the file locally. It is recommended that you save it in the resources folder of your Mendix app so that you can find it easily.

You have now created the module. The Using the Data Model Module in a Mendix App section, below, explains how to import it into your app.

Selecting an API from the SAP Catalog Service

Your SAP back end OData API is held in the SAP Catalog Service.

  1. Click SAP Catalog Service.

    You will be asked to sign in to you SAP Service Catalog. Enter your User name, Password, and Server. Select the correct protocol and Port if these are not the default.

  2. Click Next.

    You will be presented with a list of OData API definitions. You can search this list (this includes text in the API description as well as the API name), and page through it using the paging buttons.

  3. Click the API you want. It will be highlighted.

  4. Click Next to see the schemas within the API.

  5. Click the schema you want. It will be highlighted.

  6. Click Next to proceed to the confirmation screen.

  7. Click Generate .mpk to generate the data model module.

  8. Click Download.

    Your browser will offer options on what to do with the file.

  9. Save the file locally. It is recommended that you save it in the resources folder of your Mendix app so that you can find it easily.

You have now created the module. The Using the Data Model Module in a Mendix App section, below, explains how to import it into your app.

Uploading an OData Metadata XML File

You may want to generate the data model by hand using the $metadata file directly. This may, for example, not be in the API Business Hub.

One way to do this is by getting the OData metadata XML file. This file can be download from the OData service URL directly using the $metadata suffix. The browser will display the XML and you can use the right mouse button in most browsers to choose to download the XML file. Save the file locally. It is recommended that you save it in the resources folder of your Mendix app so that you can find it easily.

  1. Download the XML metadata file to your local drive.

  2. Open the Model Creator for SAP Integrations to generate a Domain Model for an SAP OData Service.

  3. Click Upload File.

  4. Drag the file you want into the Model Creator, or click Upload and upload the XML file you want to use.

  5. Click Next to see the schemas within the metadata.

  6. Click the schema you want. It will be highlighted.

  7. Click Next to proceed to the confirmation screen.

  8. Click Generate .mpk. A progress bar will be shown during the parsing and generation of the module.

  9. Once the generation is complete, the Download File button appears. Notice that the file name of your data model module is extracted from the metadata file itself.

  10. Click Download.

    Your browser will offer options on what to do with the file.

  11. Save the file locally. It is recommended that you save it in the resources folder of your Mendix app so that you can find it easily.

You have now created the module. The Using the Data Model Module in a Mendix App section, below, explains how to import it into your app.

Providing the URL to the Metadata

You can also generate the data model from the metadata by providing the URL to the Model Creator for SAP Integrations.

  1. Click URL on the OData page of the Model Creator for SAP Integrations.

  2. Enter the URL of the service metadata which you want in Enter a URL.

  3. Click Continue to see the schemas within the metadata.

  4. Click the schema you want. It will be highlighted.

  5. Click Continue to proceed to the confirmation screen.

  6. Click Generate .mpk. A progress bar will be shown during the parsing and generation of the module.

  7. Once the generation is complete, the Download File button appears. Notice that the file name of your data model module is extracted from the metadata file itself.

  8. Click Download File.

    Your browser will offer options on what to do with the file.

  9. Save the file locally. It is recommended that you save it in the resources folder of your Mendix app so that you can find it easily.

You have now created the module. The Using the Data Model Module in a Mendix App section, below, explains how to import it into your app.

Create a Mendix BAPI Module Using the Model Creator

Use Model Creator for SAP Integrations to generate a Mendix BAPI module containing the domain model for a BAPI using the schema file downloaded from BAPI explorer.

  1. Go to Model Creator for SAP Integrations and click SAP BAPI.

  2. Upload a BAPI schema file and click Next.

  3. Select the entities you need, then click on the related number of Included Attributes to go to attribute selection page for each of the entities.

  4. For each entity, select the attributes you need to include and click Save. The number of selected attributes number will be reflected in the Included Attributes column.

    This step must be repeated for every entity you want to include in the domain model.

  5. Once you have selected all the entities and attributes you need, click Next to review the selection.

  6. Review the selection and click Generate Domain Model.

  7. Click Generate .mpk to create the module containing the BAPI domain model.

  8. Click Download to save the Mendix BAPI module for this BAPI schema.

Using the Data Model Module in a Mendix App

Now you have a Mendix module ready to import into your app.

  1. Open the app which you created as a prerequisite.

  2. Right-click your app in the App Explorer and select Import module package….

  3. Use the navigation dialog to find your module, which will have the suffix .mpk.

    You now have your service module, for example GWSAMPLE_BASIC, available in your app ready to use in combination with the OData Connector for SAP Solutions.

For more information on how to use the imported data model together with the OData Connector for SAP Solutions, see OData Connector for SAP Solutions.

Read More