1 Introduction
SAP data models reflect an OData service from SAP back-end systems like SAP Business Suite (SAP ERP 6.0), SAP S/4HANA, and SAP S/4HANA Cloud. OData services are exposed via SAP Gateway and are described in a $metadata
file, which describes all the entities, relationships, and functions that are exposed for that service.
Handcrafting a Mendix domain model for these OData services would be a lot of work. The OData Model Creator for SAP solutions automates this process by creating a Mendix module for the selected service containing the Mendix domain model which can be imported in your project. 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.
There are four ways to create the data model:
- Using the API Business Hub
- Selecting an API from the SAP Catalog Service
- Uploading an Odata Metadata XML File
- Providing the URL to the Metadata
2 Prerequisites
Before starting this how-to, make sure you have completed the following prerequisites:
- Identify the SAP back-end system and OData service you wish to use
- Create an app in Mendix Studio Pro (version 7.23.6 or above)
- Obtain authentication credentials, if needed, for the SAP Catalog Service or SAP back-end system you wish to use
OData Model Creator for SAP solutions will produce a module which is in Mendix version 7.23.6. To use the module you will have to create your app in, or upgrade your app to, Mendix version 7.23.6 or above.
OData Model Creator for SAP solutions only supports SAP OData Gateway Services which use OData version 2 or version 3. OData version 4 is not yet supported.
3 Generating a Data Model
The OData Model Creator for SAP solutions is an app in the Marketplace. Search for it in the Mendix Marketplace, or find it here: OData Model Creator for SAP solutions.
The OData Model Creator for SAP solutions is not currently available in the Marketplace within Studio Pro. It can only be run in a browser.
Open the OData Model Creator for SAP solutions, where you will be asked how you want to generate your model:
There are four ways to generate your data model.
- If your SAP back-end system stores the OData API package on the SAP API Business Hub, you can create the data model from there; select API Business Hub as the source and continue with Using the API Business Hub
- If your SAP API is in the SAP Catalog Service, you can create the data model from there; select SAP Catalog Service and continue with Selecting an API from the SAP Catalog Service
- If you have access to the metadata file, select Manual and continue with Uploading an Odata Metadata XML File
- If you have the metadata URL for the OData service, select URL and continue with Providing the URL to the Metadata
3.1 Using the API Business Hub
Your SAP back-end OData API is held in the API Business Hub.
There may be several schemas in the packages of an API. Each of these will generate a module. Depending on the functionality of your app, you may have to generate several modules and import all of them into your app.
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.
You can return to any stage in this process by clicking on the relevant step number.
Click the package you want. It will be highlighted.
Click Continue to see the APIs within the package.
This will be shown even if only one API exists.
Click the API you want. It will be highlighted.
Click Continue to see the schemas within the API.
This will be shown even if only one schema exists.
Click the schema you want. It will be highlighted.
Click Continue to proceed to the confirmation screen.
Click Generate .mpk to generate the data model module.
Click Download File.
Your browser will offer options on what to do with the 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.
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.
3.2 Selecting an API from the SAP Catalog Service
Your SAP back-end OData API is held in the SAP Catalog Service.
There may be several schemas in the packages of an API. Each of these will generate a module. Depending on the functionality of your app, you may have to generate several modules and import all of them into your app.
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.
Click Continue.
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.
You can return to any stage in this process by clicking on the relevant step number.
Click the API you want. It will be highlighted.
Click Continue to see the schemas within the API.
This will be shown even if only one schema exists.
Click the schema you want. It will be highlighted.
Click Continue to proceed to the confirmation screen.
Click Generate .mpk to generate the data model module.
Click Download.
Your browser will offer options on what to do with the 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.
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.
3.3 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.
Download the XML metadata file to your local drive.
Open the OData Model Creator for SAP solutions
Click Manual.
Click Browse and navigate to the XML file you want to use.
Select the XML file you want to use.
Click Continue to see the schemas within the metadata.
This will be shown even if only one schema exists.
Click the schema you want. It will be highlighted.
Click Continue to proceed to the confirmation screen.
Click Generate .mpk. A progress bar will be shown during the parsing and generation of the module.
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.
Click Download File.
Your browser will offer options on what to do with the 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.
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.
3.4 Providing the URL to the Metadata
You can also generate the data model from the metadata by providing the URL to the OData Model Creator for SAP solutions.
This method does not work where the destination needs authentication. You cannot use it, for example, to generate a data model for a service on the ES5 Gateway Demo.
Click URL on the first page of the OData Model Creator for SAP solutions.
Enter the URL of the service metadata which you want in Enter a URL.
Click Continue to see the schemas within the metadata.
This will be shown even if only one schema exists.
Click the schema you want. It will be highlighted.
Click Continue to proceed to the confirmation screen.
Click Generate .mpk. A progress bar will be shown during the parsing and generation of the module.
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.
Click Download File.
Your browser will offer options on what to do with the 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.
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.
4 Using the Data Model Module in a Mendix App
Now you have a Mendix module ready to import into your project.
Open the project which you created as a prerequisite.
Right-click your project in the Project Explorer and select Import module package….
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 project ready to use in combination with the OData Connector for SAP solutions.
Do not change the names of entities, attributes, or associations in the Domain Model of the module; they need to match the names used by the SAP OData service for the OData Connector for SAP solutions to work correctly.
For more information on how to use the imported data model together with the OData Connector for SAP solutions, see How to Use the OData Connector for SAP Solutions.