Search code examples
c#sap-dotnet-connector

SAP connector 3.0 .NET set value on table structure


I'm trying to get data from SAP via SAP Connector 3.0 on a MVC3 application.

There is no problems with the connection.

My problem is when I try to set values on a structure from a table it says

"TABLE [STRUCTURE ZHRS_ABSENCES]: cannot set value (array storing element values is null)"

My code is the following:

//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

Solution

  • I'm not sure about the connector you're using, but there's a similar common misunderstanding when using JCo. A table parameter can hold multiple lines. You'll usually have to append a line to the table. This will probably return some kind of structure that you'll be able to fill. Also check this answer.