我正在尝试通过SAP Connector 3.0在MVC3应用程序上从SAP获取数据。
连接没有问题。
我的问题是当我尝试从表格
的表格中设置值时“TABLE [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
答案 0 :(得分:3)
我不确定您使用的连接器,但在使用JCo时存在类似的常见误解。表参数可以包含多行。您通常需要在表格中添加一行。这可能会返回一些你能够填充的结构。 Also check this answer.
答案 1 :(得分:2)
我认为您在尝试调用SetValue
之前只需要添加一个新行e.g。
absenceHoli.Append();
absenceHoli.SetValue("ColumnName", "0000483"); // Add further SetValue statements for further columns
您可以通过在获得表结构并检查它之后设置断点来获取列名,这可能比仅指定列索引更好。
答案 2 :(得分:0)
就我而言,我需要使用Insert
:
absenceHoli.Insert();
absenceHoli.SetValue(..., ...);