Im having a bit of difficulty gettign data retrieved as a IrfcStructure correctly formatted in to a asp datagrid. When bound to the grid, the data binds to vertically to a column with many rows (as opposed to one row with columns for each field). as well as this, it creates on column per row it creates with each column repeating the data again and again.
I have had success with binding Irfctbles, but it seems that structures are my nemisis!.
Any ideas anyone?
Try dumping the structure to a datatable and binding the datatable. Rough untested example below
Dim rowTable As New DataTable
For i As Integer = 0 To sapStructure.ElementCount - 1
Dim row As DataRow = rowTable.NewRow()
For j As Integer = 0 To sapStructure.ElementCount - 1
row(j) = sapStructure.GetValue(j)
Thank you for the pointer - just to confirm if anyone else needs to do this:
this is the method I am now successfully using (C#)
public DataTable ConvertStructure(IRfcStructure myrefcTable) //Convert RFCStructure to datatable
DataTable rowTable = new DataTable();
for (int i = 0; i <= myrefcTable.ElementCount - 1; i++)
DataRow row = rowTable.NewRow();
for (int j = 0; j <= myrefcTable.ElementCount - 1; j++)
row[j] = myrefcTable.GetValue(j);
Call this method in your code by using:
IRfcStructure customerTable = bapiCheckCustomer.GetStructure("BAPI_NAME");
dataGridView1.DataSource = ConvertStructure(customerTable);