on 05-31-2012 9:18 AM
Hi,
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?
Many thanks
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
rowTable.Columns.Add(sapStructure.GetElementMetadata(i).Name)
Next
Dim row As DataRow = rowTable.NewRow()
For j As Integer = 0 To sapStructure.ElementCount - 1
row(j) = sapStructure.GetValue(j)
Next
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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++)
{
rowTable.Columns.Add(myrefcTable.GetElementMetadata(i).Name);
}
DataRow row = rowTable.NewRow();
for (int j = 0; j <= myrefcTable.ElementCount - 1; j++)
{
row[j] = myrefcTable.GetValue(j);
}
rowTable.Rows.Add(row);
return rowTable;
}
Call this method in your code by using:
IRfcStructure customerTable = bapiCheckCustomer.GetStructure("BAPI_NAME");
dataGridView1.DataSource = ConvertStructure(customerTable);
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
101 | |
13 | |
13 | |
11 | |
11 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.