sap IRfcTable 转成 DataTable

public DataTable GetDataTableFromRFCTable(IRfcTable myrfcTable)

{

DataTable loTable = new DataTable();

int liElement = 0;

for (liElement = 0; liElement <= myrfcTable.ElementCount - 1; liElement++)

{

RfcElementMetadata metadata = myrfcTable.GetElementMetadata(liElement);

   loTable.Columns.Add(metadata.Name);

}

foreach (IRfcStructure Row in myrfcTable)

{

DataRow ldr = loTable.NewRow();

for (liElement = 0; liElement <= myrfcTable.ElementCount - 1; liElement++)

{

RfcElementMetadata metadata = myrfcTable.GetElementMetadata(liElement);

ldr[metadata.Name] = Row.GetString(metadata.Name);

}

   loTable.Rows.Add(ldr);

}

return loTable;

}

posted @ 2013-10-17 14:35  jamin  阅读(2883)  评论(0编辑  收藏  举报