当我尝试调用 IRfcFunction 时,我遇到了 RfcCommunicationException 问题。我可以像这样处理 BAPI_MATERIAL_GETLIST 并得到结果:
SAPSystemConnect cfg = new SAPSystemConnect();
RfcDestinationManager.RegisterDestinationConfiguration(cfg);
RfcDestination dest = RfcDestinationManager.GetDestination("mySAPdestination");
RfcRepository repo = dest.Repository;
IRfcFunction func = repo.CreateFunction("BAPI_MATERIAL_GETLIST");
IRfcTable tbl = func.GetTable("MATNRSELECTION");
tbl.Append();
tbl.SetValue("SIGN", "I");
tbl.SetValue("OPTION", "BT");
tbl.SetValue("MATNR_LOW", "10");
tbl.SetValue("MATNR_HIGH", "20");
func.SetValue("MATNRSELECTION", tbl);
IRfcTable tbl2 = func.GetTable("MATNRLIST");
func.Invoke(dest);
DataTable dt = tbl2.ToDataTable("table1");
foreach (DataRow row in dt.Rows)
{
Console.WriteLine("{0}", row.Field<string>(0));
}
但是当我尝试处理 BAPI_FUNCLOC_GETLIST 时,我得到了一个带有以下代码的 RfcCommunicationException:
SAPSystemConnect cfg = new SAPSystemConnect();
RfcDestinationManager.RegisterDestinationConfiguration(cfg);
RfcDestination dest = RfcDestinationManager.GetDestination("mySAPdestination");
RfcRepository repo = dest.Repository;
IRfcFunction func = repo.CreateFunction("BAPI_FUNCLOC_GETLIST");
IRfcTable tbl = func.GetTable("FUNCLOC_RA");
tbl.Append();
tbl.SetValue("SIGN", "I");
tbl.SetValue("OPTION", "CP");
tbl.SetValue("LOW", "MY-FL*");
func.SetValue("FUNCLOC_RA", tbl);
IRfcTable tbl2 = func.GetTable("FUNCLOC_LIST");
func.Invoke(dest); // I get an RfcCommunicationException here that says
// "Syntax or generation error in a screen."
DataTable dt = tbl2.ToDataTable("table1");
foreach (DataRow row in dt.Rows)
{
Console.WriteLine("{0}", row.Field<string>(0));
}
我按照此处的说明进行操作,但似乎无法让 BAPI_FUNCLOC_GETLIST 进行处理。