文章目录
- 用C#调用SAP 的WebServices接口
- 创建C#的项目
- 添加窗体
- 添加引用
- 在表单的装载事件里编写代码
- 运行结果
- SAP的RFC函数
用C#调用SAP 的WebServices接口
创建C#的项目
添加窗体
添加引用
在表单的装载事件里编写代码
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace WebApplication3_SAP
{
public partial class WebServicesTest_Form : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
System.Net.NetworkCredential c = new System.Net.NetworkCredential("KN089", "Hsxxxxx");
WebReference.Z_WS004 z_WS004 = new WebReference.Z_WS004();
WebReference.ZTestRfcEkpoLhy Data = new WebReference.ZTestRfcEkpoLhy();
Data.IEbeln = "4500000003";
Data.IEbelp = "00001";
Data.IWerks = "1710";
Data.EtEkpo = new WebReference.ZtestTEkpo[1];
var res = z_WS004.ZTestRfcEkpoLhy(Data);
TextBox1.Text = res.EsEkpo.Ebeln + " " +
res.EsEkpo.Ebelp + " " +
res.EsEkpo.Matnr + " " +
res.EsEkpo.Werks + " " +
res.EsEkpo.Menge;
WebReference.ZtestTEkpo[] ztestTs = res.EtEkpo;
this.GridView1.AutoGenerateColumns = true;
this.GridView1.DataSource = ztestTs;
this.GridView1.DataBind();
}
protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
{
}
}
}
运行结果
SAP的RFC函数