---
title: "Example - Create Material Definitions"
id: "example-create-material-definitions"
project: "MES User Manual"
url: "https://docs.sepasoft.com/articles/user-manual/example-create-material-definitions"
updated: 2026-07-31T14:57:06Z
---

# Example \- Create Material Definitions

**Sepasoft MES Module Suite**
 This example chart collects a list of Material Definitions from an SAP database and creates a MES Material Definition object for each.

![](/resources/Storage/user-manual/example-create-material-definitions/SAP%20RFM%20Action%20Block%20-%20Example%20Chart.PNG)

 * * *

 ### Start Block

A Chart Parameter called **maxRows** is used to limit the number of SAP entries to fetch from the SAP database. The number will be input into the chart during the chart execution function [executeChart(chartPath, chartParameters)](/docs/display/BC/system.mes.bc.executeChart).

 | Sample Setting | Description |
| --- | --- |
| maxRows | Integer type. It will become available for mapping in the SAP RFM Action Block. |

![](/resources/Storage/user-manual/example-create-material-definitions/Start%20Block%20-%20Example%20Chart%20-%20Properties.PNG)

 * * *

 ### SAP RFM Action Block - Properties

This block fetches the Material Definitions from the specified SAP database. It is configured as follows:

A Destination called **My SAP Server** was previously configured in the **Interface for SAP ERP** section of the Global area in Designer:

![](/resources/Storage/user-manual/example-create-material-definitions/image2019-3-20_11-53-31.png)

![](/resources/Storage/user-manual/example-create-material-definitions/SAP%20RFM%20Action%20Block%20-%20Properties%20Pane%202.PNG)

 The **Remote Function Call** section is configured to filter down to just the **BAPI\_MATERIAL\_GETLIST** module where the Material Definitions are stored:

 | Property | Sample Setting | Description |
| --- | --- | --- |
| Name | Get Materials | Name of the Block (available, if needed, for local use within the chart by other Blocks). |
| Destination | My SAP Server | Selected SAP Connector Destination (created in the Interface for SAP section of the Global area in Designer). |
| Function Group Filter | \* | All SAP Groups will pass through the filter (asterisk is a wildcard). |
| Function Module Filter | \*material\_getlist | SAP function call to retrieve the list of material group objects. |
| Function Group | (Any Function Group) | The Function Modules for all SAP Function Groups will be available in the Function Module drop-down list. |
| Function Module | BAPI\_MATERIAL\_GETLIST | Retrieve only the BAPI Materials list. |
| Selected RFM | (shows the selected Function Module) | Display only. Shows the selected Function Module after the **Select** button is pushed. |
| RFC Type | sRFC | Synchronous Remote Function Call (expects an immediate answer from the receiving system, else an error will be reported). |
| Queue Name | N/A |  |

 ### SAP RFM Action Block - Mapping

The **Input** tab of the SAP RFM Action Block includes mapping for the Chart Parameter **maxRows** to be passed into the RFM function call that the block makes to the SQL database (limits the number of entries fetched). There is also a requirement that **MATNRSELECTION** in **BAPI\_MATERIAL\_GETLIST** be restricted to positive integer values only.

![](/resources/Storage/user-manual/example-create-material-definitions/SAP%20RFM%20Action%20Block%20-%20Input%20Mapping_1x.png)

The **Output** tab of the SAP RFM Action Block includes mapping for **MATERIAL → ID** and **MATL\_DESC → Description**. Note that it must first include a mapping connector at the parent level, to provide the block with a means of knowing the array sizes on both sides so it can map the connections properly. Each member of the **BAPI\_MATERIAL\_GETLIST** will be mapped into a B2MML array that includes Material Definition properties of **ID** and **Description**. These will be turned into MES Material Definition objects by the SAVE MES Object Block (see below).

![](/resources/Storage/user-manual/example-create-material-definitions/Sample%20Chart%20-%20Basic%20Materials%20-%20Output%20Mapping.png)

 * * *

### Save MES Object Block

This block creates an MES Object for each entry in the selected RFM (the drop-down list **Target** will list all of the Action Blocks in the chart. The filtered RFM in the selected Action Block will be used to create the list of MES Objects). For this example, one MES Material Definition object will be created for each entry in the RFM selected in the "Get Materials" SAP RFM Action Block (up to the limit defined by the Chart Parameter **maxRows**).

 | Property | Sample Setting | Description |
| --- | --- | --- |
| Target | Get Materials | "Get Materials" is the data source selected from the drop-down list of blocks with available data (it's the only choice in this example). |

![](/resources/Storage/user-manual/example-create-material-definitions/Save%20MES%20Object%20Block%20-%20example.PNG)

 * * *

 ### End Block

The End Block has no properties. When control passes to this block, it returns control to the script that executed the chart execution function [executeChart(chartPath, chartParameters)](/docs/display/BC/system.mes.bc.executeChart).

![](/resources/Storage/user-manual/example-create-material-definitions/End%20Block%20-%20no%20Properties.PNG)

 * * *

 ### Executing the Chart

This example chart is being executed from a script within a Button component on an Ignition Designer window:

![](/resources/Storage/user-manual/example-create-material-definitions/Button%20Script.PNG)

If "**10**" is entered into the **Rows to Fetch** text field, then when the Button is pressed:

* The number in the text field is loaded into **numRows**.
* "***Fetching 10 rows from BAPI\_MATERIAL\_GETLIST***" is printed to the Output Console.
* The chart is executed, passing in **numRows** to the Chart Parameter **maxRows** in the Start Block. Script execution in the Button script will  wait for the chart to complete its execution, allowing the chart to run independently in the background.

The result of the chart execution is that ten rows are fetched from **BAPI\_MATERIAL\_GETLIST** in the SAP database and ten **MES Material Definition** objects are created:

![](/resources/Storage/user-manual/example-create-material-definitions/MES%20Object%20Editor%20results.PNG)

![](/resources/Storage/user-manual/example-create-material-definitions/Button%20in%20Window.PNG)

![](/resources/Storage/user-manual/example-create-material-definitions/Output%20Console%20results.PNG)

**Sepasoft MES Module Suite**