Skip to content

Transactions

This section shows how to use the Transaction class to execute SAP transactions.

About Transactions

ERPConnect can execute SAP transactions as a foreground or as a background process (Batch Input).

When executing transactions in a background process, mass data can be processed and transferred to the SAP system. This technique is often used if no suitable BAPI exists.

For more information on SAP transactions, see SAP Help: Using Transaction Codes.

Execute SAP Transactions

To run SAP transactions from ERPConnect:

  1. Connect to the SAP system using R3Connection. Set the UseGui property to true.
  2. Create a transaction object using Transaction().
  3. Specify the SAP transaction code using TCode.
  4. Optional: add batch steps using AddStep.
  5. Launch the SAP GUI and execute the SAP transaction using Execute.

Tip

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

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

Execute SAP Transaction MMBE
using System;
using ERPConnect;
using ERPConnect.Utils;

// Set your ERPConnect license
LIC.SetLic("xxxx");

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

connection.Open();

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.AddStepSetOKCode("ONLI");
transaction.AddStepSetCursor("MS_WERKS-LOW");
transaction.AddStepSetField("MS_MATNR-LOW", material);
transaction.AddStepSetField("MS_WERKS-LOW", plant);

// run
transaction.Execute();

Input:

Material: 100-100
Plant: 1000

Output:

Call-Transaction-003



Last update: June 25, 2026