2011-01-24 55 views
2

我有一個函數,其中一個參數是一個表(T_ITEMS)。添加項目到IRfcTable

表的項目類型/結構Z_ITEM有兩個字段:值,數量;

如何在此表中添加Z_ITEM類型的項目?

我所做的是下面的代碼:

IRfcFunction fnct = repo.CreateFunction("MY_FUNCTION"); 
IRfcTable t_items = fnct.GetTable("T_ITEMS"); 

foreach(XmlNode oneNode in postdata.Items.SelectNodes("//articles/article")) { 
    IRfcStructure articol = repo.GetStructureMetadata("Z_ITEMS") as IRfcStructure; 
    articol.SetValue("Value", oneNode.Attributes[ "value" ].Value); 
    articol.SetValue("Quantity", oneNode.Attributes[ "quantity" ].Value); 
    t_items.Append(articol); 
} 

在repo.GetStructureMetadata(「Z_ITEMS」)我有結構的,但是當我投來 IRfcStructure變量articol爲空。

回答

5

已解決。

IRfcStructure articol = repo.GetStructureMetadata("Z_ITEMS") as IRfcStructure; 

通過

RfcStructureMetadata am = repo.GetStructureMetadata("Z_ITEMS"); 
IRfcStructure articol = am.CreateStructure(); 
替換