Model Creator for SAP Integrations
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:
- 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
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.
- 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
Using the API Business Hub
Your SAP back end OData API is held in the API Business Hub.
-
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 Next 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 Next 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 Next 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.
Selecting an API from the SAP Catalog Service
Your SAP back end OData API is held in the SAP Catalog Service.
-
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 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.
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 Next 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 Next 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.
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 Model Creator for SAP Integrations to generate a Domain Model for an SAP OData Service.
-
Click Upload File.
-
Drag the file you want into the Model Creator, or click Upload and upload the XML file you want to use.
-
Click Next 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 Next 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.
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.
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.
-
Click URL on the OData page of the Model Creator for SAP Integrations.
-
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.
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.
-
Go to Model Creator for SAP Integrations and click SAP BAPI.
-
Upload a BAPI schema file and click Next.
-
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.
-
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.
-
Once you have selected all the entities and attributes you need, click Next to review the selection.
-
Review the selection and click Generate Domain Model.
-
Click Generate .mpk to create the module containing the BAPI domain model.
-
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.
-
Open the app which you created as a prerequisite.
-
Right-click your app in the App 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 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
- How to Use Marketplace Content
- OData Connector for SAP Solutions
- Model Creator for SAP Integrations (SAP)