The previous example showed how the ExecuteTableQuery method of class ERPConnectServiceClient can be used to query a table in the SAP. Depending on the type of application, the ExecuteTableQuery method returns the result set as data structure DataTable or as a similar data structure ERPDataTable. For SharePoint and desktop applications you can use the ExecuteTableQuery in the following ways:

Click to open C# example.
public DataTable ExecuteTableQuery(string tableName)
public DataTable ExecuteTableQuery(string tableName, ExecuteTableQuerySettings settings)

The following example illustrates how material descriptions that are stored in SAP table MAKT can be read. First, you create an instance of ERPConnectServiceClient by specifying the public URL for the SharePoint server. To read material descriptions in English language only, we add the criteria SPRAS = ‘EN’ to the WhereClause. The value SPRAS represents the column which stores the language key in table MAKT. Only the first ten records will be returned (RowCount = 10).

Click to open C# example.
using ERPConnectServices;
// ... 
ERPConnectServiceClient client = new ERPConnectServiceClient("http://SERVERNAME"); 
DataTable dt = client.ExecuteTableQuery("MAKT", 
new ExecuteTableQuerySettings { 
RowCount = 10, 
WhereClause = "SPRAS = 'EN'" 
});

If you only want to return certain columns of the table, you can use the Fields property of the class ExecuteTableQuerySettings:

Click to open C# example.
Fields.Add("ColumnName");

The picture below shows the data returned by the query example.

ECS-VS-Table-Preview