Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add multiple rows to IRfcTable

I am trying to pass 2 rows to a BAPI table, but my code is taking only the 2nd row all the times.

I is passing the data as:

6 7 8
6 7 8

instead of:

1 2 3
6 7 8

Here's what I've tried:

IRfcFunction bapiTEST = _rfcDest.Repository.CreateFunction(strBapi);

IRfcStructure structImport = _rfcDest.Repository.GetStructureMetadata("ZBAPI_A_STRU_ORDER_CLICK").CreateStructure();

structImport.SetValue("NUM1", "000001");
structImport.SetValue("NUM2", "000002");
structImport.SetValue("NUM3", "000003");

IRfcTable tblImport = bapiTEST.GetTable("IMPORT");
tblImport.Insert(structImport);

structImport.SetValue("NUM1", "000006");
structImport.SetValue("NUM2", "000007");
structImport.SetValue("NUM3", "000008");

tblImport.Insert(structImport);
bapiTEST.SetValue("IMPORT", tblImport);

RfcSessionManager.BeginContext(_rfcDest);
bapiTEST.Invoke(_rfcDest);
like image 468
Venky Avatar asked Nov 30 '25 21:11

Venky


1 Answers

I think you're reusing structImport, so the second time you're calling SetValue is also affecting the first structImport you inserted. Try calling another CreateStructure() in between.

like image 185
René Avatar answered Dec 03 '25 09:12

René