I can't understand the documentation and really need a concrete example.
I've already created the destination. Here I define my BAPI:
IRfcFunction BapiIncomingInvoiceGetDetail = SapRfcRepository.CreateFunction("BAPI_INCOMINGINVOICE_GETDETAIL");
Set my imports, invoke it, and then get my exports - one of which is a table:
IRfcTable ITEMDATATable = BapiIncomingInvoiceGetDetail.GetTable("ITEMDATA");
I now want to add a field to each item in the table ITEMDATATable and set its' value so I can reference it later as if it were one of thefields returned by the BAPI. Can anyone tell me how?
EDIT: Okay, I've made some progress:
RfcFieldMetadata newField = new RfcFieldMetadata("SKU_AMT",0,0,0);
ITEMDATATable.CurrentRow.Metadata.AddField(newField);
ITEMDATATable.SetValue("SKU_AMT",myItemData.SKU_AMT);
However, when I try to set the value, I get RfcInvalidStateException "Cannot add an element to locked STRUCTURE BAPI_INCINV_DETAIL_ITEM".
Any way around this?
you can't append columns to the table, the fields are already defined. You need to add a row to the table and populate the fields of that row. This should work (although i can't test it right now):
IRfcTable ITEMDATATable = BapiIncomingInvoiceGetDetail.GetTable("ITEMDATA");
ITEMDATATable.Append();
ITEMDATATable.SetValue("SKU_ATM",myItemData.SKU_AMT);