表结构上的SAP连接器3.0 .NET设置值

问题描述 投票:1回答:3

我正在尝试通过MVC3应用程序上的SAP Connector 3.0从SAP获取数据。

连接没有问题。

我的问题是,当我尝试从表中说的结构中设置值时

“表[STRUCTURE ZHRS_ABSENCES]:无法设置值(存储元素值的数组为null)”

我的代码如下:

//create function    
IRfcFunction function = conex.Repository
                        .CreateFunction("Z_HR_PORTAL_GET_EMPLOYEE_DATA");

//get table from function
IRfcTable absenceHoli = function.GetTable("P_ABSENCES");

//setting value to structure
absenceHoli.SetValue(0, "0000483"); //this is where the error occurs
c# .net sap connector sap-connector
3个回答
3
投票

我不确定您使用的连接器,但是使用JCo时也有类似的常见误解。一个表参数可以容纳多行。通常,您必须在表格中添加一行。这可能会返回某种您可以填充的结构。 Also check this answer.


3
投票

我认为您只需要在尝试调用SetValue之前追加一个新行

例如

absenceHoli.Append();    
absenceHoli.SetValue("ColumnName", "0000483"); // Add further SetValue statements for further columns 

[获得表结构后检查断点,可以得到列名,这可能比仅指定列索引更好。


0
投票

就我而言,我需要使用Insert

absenceHoli.Insert();
absenceHoli.SetValue(..., ...);
© www.soinside.com 2019 - 2024. All rights reserved.