原文地址:http://www.cnblogs.com/flysky927/archive/2009/01/03/1367684.html
logon.ApplicationServer = ""; //SAP system's IP
logon.Client = ""; //SAP system'client
logon.Language = "EN";
logon.User = ""; //Username
logon.Password = ""; //Password
logon.SystemNumber = 00; //System number
SAPLogonCtrl.Connection conn = (SAPLogonCtrl.Connection)logon.NewConnection();
{
SAPFunctionsOCX.SAPFunctionsClass func = new SAPFunctionsOCX.SAPFunctionsClass();
func.Connection = conn;
SAPFunctionsOCX.IFunction ifunc = (SAPFunctionsOCX.IFunction)func.Add("ENQUEUE_READ"); //Call Function module 'ENQUEUE_READ'
SAPFunctionsOCX.IParameter gclient = (SAPFunctionsOCX.IParameter)ifunc.get_Exports("GCLIENT"); //Get the import paremeter
gclient.Value = "301"; //Set value for import paremeter
SAPFunctionsOCX.IParameter GUNAME = (SAPFunctionsOCX.IParameter)ifunc.get_Exports("GUNAME");
GUNAME.Value = "";
SAPFunctionsOCX.IParameter LOCAL = (SAPFunctionsOCX.IParameter)ifunc.get_Exports("LOCAL");
LOCAL.Value = "0";
ifunc.Call();
SAPFunctionsOCX.IParameter NUMBER = (SAPFunctionsOCX.IParameter)ifunc.get_Imports("SUBRC");
SAPTableFactoryCtrl.Tables ENQs = (SAPTableFactoryCtrl.Tables)ifunc.Tables; //get all the tables
SAPTableFactoryCtrl.Table ENQ = (SAPTableFactoryCtrl.Table)ENQs.get_Item("ENQ"); //Get table 'ENQ'
int n = ENQ.RowCount;
DataTable dt = CreateTable();
for (int i = 1; i <= n; i++)
{
DataRow dr = dt.NewRow();
dr["GNAME"] = ENQ.get_Cell(i, "GNAME").ToString(); //Get cell information
dr["GUNAMe"] = ENQ.get_Cell(i, "GUNAME").ToString();
dr["GARG"] = ENQ.get_Cell(i, "GARG").ToString();
dr["GOBJ"] = ENQ.get_Cell(i, "GOBJ").ToString();
dr["GTDATE"] = ENQ.get_Cell(i, "GTDATE").ToString();
dt.Rows.Add(dr);
}
dataGridView1.DataSource = dt;
dataGridView1.Visible = true;
label1.Text = "Get data from FM 'ENQUEUE_READ' OK!";
}
else
label1.Text = "NO";
}
这样就可以在form中调用SAP ECC中的