如何使用sap .net连接器从SAP系统获取数据?

我正在开发一个 Windows应用程序,在这里我想从sap系统中提取数据并在datagridview中显示它…
我已经单独提取了列名,如名称,城市等.

我不知道如何从列中提取数据,任何人都可以帮我解决这些问题吗?

我正在使用RFC_READ_TABLE函数模块和rfc destiantion manager

提前致谢!!!

解决方法

未经测试,但这基本上是它的工作原理:

首先创建连接

RfcDestination destination = mDestinationManager.GetDestination("MYDESTINATION");

创建功能

IRfcFunction readTable = destination.Repository.CreateFunction("RFC_READ_TABLE");

调用函数之前设置参数

// we want to query table KNA1
readTable.SetValue("QUERY_TABLE","KNA1");
// fields will be separated by semicolon
readTable.SetValue("DELIMITER",";");

表参数是通过从函数中检索表来创建的,使用Append()函数添加行并使用SetValue()为该行中的各个列设置值

// Parameter table FIELDS contains the columns you want to receive
// here we query 2 fields,KUNNR and NAME1
IRfcTable fieldsTable = readTable.GetTable("FIELDS");
fieldsTable.Append();
fieldsTable.SetValue("FIELDNAME","KUNNR");
fieldsTable.Append();
fieldsTable.SetValue("FIELDNAME","NAME1");

// the table OPTIONS contains the WHERE condition(s) of your query
// here a single condition,KUNNR is to be 0012345600
// several conditions have to be concatenated in ABAP Syntax,for instance with AND or OR
IRfcTable optsTable = readTable.GetTable("OPTIONS");
optsTable.Append();
optsTable.SetValue("TEXT","KUNNR = '0012345600'");

调用函数

readTable.Invoke(destination);

处理数据

IRfcTable dataTable = readTable.GetTable("DATA");

foreach(var daTarow in dataTable)
{
    string data = daTarow.GetValue("WA");
    string[] columns = data.Split(';');
}

相关文章

Windows2012R2备用域控搭建 前置操作 域控主域控的主dns:自...
主域控角色迁移和夺取(转载) 转载自:http://yupeizhi.blo...
Windows2012R2 NTP时间同步 Windows2012R2里没有了internet时...
Windows注册表操作基础代码 Windows下对注册表进行操作使用的...
黑客常用WinAPI函数整理之前的博客写了很多关于Windows编程的...
一个简单的Windows Socket可复用框架说起网络编程,无非是建...