与 SAP 集成
我正在创建一个与 SAP 集成的系统。
客户给了我函数和参数,据他说,这个函数通常是在 SAP 中执行的,但在我的代码中,当我尝试检索参数时,它返回 null。
这是我的代码(编辑:基于 SAP GUI for Windows 中提供的 RFC 客户端):
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");
在互联网上搜索发现了几个与我的类似的示例, 这里,这里和这里!
为什么方法 get_Exports("MATNR");
返回 null?
I am creating a system to integrate with SAP.
The client gave me the function and parameters, according to him, this function was usually performed in SAP but in my code when I try to retrieve the parameter, it returns me null.
Here's my code (EDIT: based on the RFC client provided within SAP GUI for Windows):
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");
Searching the internet found several examples similar to mine,
here, here and here!
Why the method get_Exports("MATNR");
returns null?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
为您提供的 RFC 功能的确切参数是什么?
在第一部分中,您似乎在循环表的列名,而在第二部分中,您正在搜索参数(即不在表中)。
问候
Guillaume
PS:ABAP 是 SAP 专有语言
What are the exact parameters that where given to you for the RFC function ?
In the first part you seems to be looping over the column name of a table, and in the second one, you're searching for a parameter (ie not in the table).
regards
Guillaume
PS : ABAP is SAP proprietary language
我认为您忘记了实际的函数调用,至少在代码示例中是这样
I think you forgot the actual function call, at least in the code sample