4.可以修改命名空间与类名。选择存放文件夹。再点击最大的按键,直接生成类库。
5.在VS工程中引用生成的类库文件。一个测试程序
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using ProxyBuilder;
using SAP.Connector;
using SAP.Connector.Rfc;
namespace WindowsFormsApplication2
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
this.button1.Enabled = false;
}
//声明连接
SAP.Connector.Destination dest = new Destination();
//声明代理类
ProxyBuilder.SAPProxy proxy = new ProxyBuilder.SAPProxy();
private void btnConnect_Click(object sender, EventArgs e)
{
//这里是连接的具体参数,用过SAP的人都知道。。
dest.AppServerHost = "";
dest.Client = ;
dest.Password = "";
dest.Username = "";
dest.SystemNumber = ;
SAP.Connector.SAPConnection conn = new SAPConnection(dest);
proxy.Connection = conn;
try
{
proxy.Connection.Open();
this.button1.Enabled = true;
}
catch
{
MessageBox.Show("login failed");
proxy.Connection.Close();
}
}
private void button1_Click(object sender, EventArgs e)
{
//用来保存返回表,实际上这里返回的是一个结构Wa。
ProxyBuilder.TAB512Table tb512 = new TAB512Table();
//定义字段参数
RFC_DB_FLD fld=new RFC_DB_FLD();
RFC_DB_FLDTable tbfld=new RFC_DB_FLDTable();
fld.Fieldname = "BELNR";
tbfld.Add(fld);
fld.Fieldname = "BUKRS ";
tbfld.Add(fld);
fld.Fieldname = "GJAHR ";
tbfld.Add(fld);