We don’t allow questions seeking recommendations for software libraries, tutorials, tools, books, or other off-site resources. You can edit the question so it can be answered with facts and citations.
Closed 8 years ago.
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(1)
使用 vs2010 和 SAP .NET Connector 3.0 的示例
要求:
安装
确定正确的 安装适合您平台的版本。您可能有以下内容:
.. 对于 Windows 7 64 位安装,我们将使用
sapnco30dotnet40P_12-20007348.zip
。展开存档,然后启动
.msi
安装文件。.. 按照安装过程进行操作,保留所有默认选项(下一步.. 下一步.. 下一步.. 完成)。
引用
打开 Visual Studio 并创建一个新项目(或打开您自己的项目)。
在“解决方案资源管理器”面板(通常位于右侧)中,右键单击“引用”并选择“添加引用”:
.. 然后,选择
浏览
选项卡,导航到 SAP Connector 安装文件夹,然后选择sapnco.dll
和sapnco_utils.dll
:现在您已经正确引用了 SAP .NET Connector 在您的 Visual Studio 项目中,您可以为其编写代码。
连接
首先创建目标配置类(将连接参数替换为客户端提供的连接参数):
.. 然后,连接到 SAP 并调用函数。假设您想要使用
BAPI_COMPANYCODE_GETLIST
SAP 函数检索公司列表:让生活更轻松
在上面的示例中,
GetTable
函数返回一个 SAP 您可能喜欢或不喜欢的表格。有一个方便的扩展可以在熟悉的 .NETDataTable
中转换该表,如下所示:参考:http://antswift.wordpress.com/2011/12/22/irfctable-to-net-datatable-extention-method/
添加上述扩展后,您现在可以将结果转换为
DataTable
:注意
附加阅读
An example using vs2010 and SAP .NET Connector 3.0
Requirements:
Installation
Identify the correct version for your platform. You might have something along the following:
.. for a Windows 7 64-bit installation, we'll use
sapnco30dotnet40P_12-20007348.zip
.Expand the archive, and start the
.msi
installation file... follow the installation procedure, leaving all default options (next.. next.. next.. finish).
Referencing
Open Visual Studio and create a new project (or open your own).
In the
Solution Explorer
panel, usually to your right, right-click onReferences
and chooseAdd Reference
:.. then, select the
Browse
tab, navigate to the SAP Connector installation folder, and select bothsapnco.dll
andsapnco_utils.dll
:Now that you've correctly referenced the SAP .NET Connector in your Visual Studio project, you can write code for it.
Connecting
Start by creating a destination configuration class (replace the connection parameters with the ones you're given by your client):
.. then, connect to SAP and call a function. Suppose that you want to retrieve the list of companies, using the
BAPI_COMPANYCODE_GETLIST
SAP function:Making life easier
In the above example, the
GetTable
function returns a SAP table which you may like, or not. There's a handy extension that transforms that table in a familiar .NETDataTable
, as follows:Reference: http://antswift.wordpress.com/2011/12/22/irfctable-to-net-datatable-extention-method/
After adding the above extension, you can now transform the result into a
DataTable
:Notes
Additional Reading