Theobald Software Community Day 2024: Jetzt Early Bird Ticket SICHERN und mit dem Code EARLY20 20% sparen

Reading SAP Tables Directly

A recurrent task in daily work with SAP and .NET applications is to read directly from tables of the SAP system. You can use the ReadTable class to manage this demand. The sample below shows how to select data from the table. The result is passed back via an easy-to-use table object.

In this sample we want to read material description texts which are located in the table MAKT. So we need the two columns MATNR (material number) and MAKTX (material description). Furthermore we want only the English texts so we have to add the WHERE statement SPRAS=’EN’. SPRAS is the column which contains the language keys. The method Run executes the query and passes back the table.

using System;
using ERPConnect;
using System.Data;
class Class1
    static void Main(string[] args)
        ERPConnect.R3Connection con = new R3Connection("SAPServer",00,"SAPUser","Password","EN","800");
        ERPConnect.LIC.SetLic("xxxxxxxxxxxxx"); //Set your ERPConnect License.

        con.Open();  //Open the connection to SAP.
        ERPConnect.Utils.ReadTable table = new ERPConnect.Utils.ReadTable(con);
        table.WhereClause = "SPRAS = 'EN'";    
        table.TableName = "MAKT";
        table.RowCount = 10;
        DataTable resulttable = table.Result;
        for(int i=0; i < resulttable.Rows.Count;i++)
                resulttable.Rows[i]["MATNR"].ToString() + " " +

Creation date: 4/1/2022 9:38 AM      Updated: 1/22/2024 10:01 AM