Warning: Deprecated articles
You are using the old version of the knowledge base for ERPConnect.
Make sure to use the samples within the new HelpCenter for ERPConnect.

The following sample application shows how to execute the SAP transaction MMBE (stock overview) using the Transaction class.

About #

In this application the user can enter a material number and the name of a plant. By clicking a button, the SAP GUI is launched and the transaction MMBE (stock overview) is executed to list the entered materials and plants.


Tip: The installation package of ERPConnect includes the Transaction-Recorder tool. This tool records transactions and implements them to code, see Transaction-Recorder.

The code below shows how to add batch steps with the method AddStep.
When connecting to SAP set the UseGui property to true. The SAP GUI is launched using the method Execute.

Execute SAP Transactions #

The following sample code executes the SAP transaction MMBE (stock overview):

using System;
using ERPConnect;
using ERPConnect.Utils;

// Set your ERPConnect license

using var connection = new R3Connection(
    host: "server.acme.org",
    systemNumber: 00,
    userName: "user",
    password: "passwd",
    language: "EN",
    client: "001")
    Protocol = ClientProtocol.NWRFC,
    UseGui = true,


Console.Write("Material: ");
string material = Console.ReadLine();

Console.Write("Plant: ");
string plant = Console.ReadLine();

var transaction = new Transaction(connection)
    ExecutionMode = TransactionDialogMode.ShowAll,
    TCode = "MMBE"

transaction.AddStepSetNewDynpro("RMMMBEST", "1000");
transaction.AddStepSetField("MS_MATNR-LOW", material);
transaction.AddStepSetField("MS_WERKS-LOW", plant);

// run


Material: 100-100
Plant: 1000



Note: If you only want to execute a single transaction without adding several batch steps, simply set the property TCode and execute the transaction.