我正在创建一个与 SAP 集成的系统。
客户给了我函数和参数,据他说,这个函数通常在 SAP 中执行,但在我的代码中,当我尝试检索参数时,它返回 null。
这是我的代码
SAPFunctionsOCX.SAPFunctionsClass func = new SAPFunctionsOCX.SAPFunctionsClass();
func.Connection = connection;
SAPFunctionsOCX.IFunction ifunc = (SAPFunctionsOCX.IFunction)func.Add(functionName);
SAPTableFactoryCtrl.Tables tables = (SAPTableFactoryCtrl.Tables)ifunc.Tables;
SAPTableFactoryCtrl.Table objTable = (SAPTableFactoryCtrl.Table)tables[tableName];
//Paramters (Find one column "MATNR"
SAPTableFactoryCtrl.Columns cols2 = (SAPTableFactoryCtrl.Columns)objTable.Columns;
for (int i = 1; i <= cols2.Count; i++)
{
SAPTableFactoryCtrl.Column col = (SAPTableFactoryCtrl.Column)cols2[i];
Console.WriteLine(col.Name);
}
//Error here! matnr == null
SAPFunctionsOCX.IParameter matnr = (SAPFunctionsOCX.IParameter)ifunc.get_Exports("MATNR");
在网上搜索了几个和我的类似的例子, here , here和 here !
为什么方法。 get_Exports("MATNR");返回空值?
最佳答案
为 RFC 函数提供给您的确切参数是什么?
在第一部分中,您似乎在遍历表的列名,而在第二部分中,您正在搜索一个参数(即不在表中)。
问候
纪尧姆
PS:ABAP 是 SAP 专有语言
关于c# - 与 SAP 集成,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5155258/