cancel
Showing results for 
Search instead for 
Did you mean: 

"Invalid row" error on trying to add goods receipt - SDK SAP B1

kinyanjuikamau
Explorer
0 Kudos

Hello experts,

I am getting the error: Message:System.Runtime.InteropServices.COMException (0xFFFFFFFF): Invalid row

when trying to add a goods receipt. I want to add 2 rows of the same item that are batched.

What am I doing wrong?

SAPbobsCOM.Documents goodsReceipt = (SAPbobsCOM.Documents)oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oInventoryGenEntry);

goodsReceipt.DocDate = DateTime.Now;

string monthName = DateTime.Now.ToString("MMM", CultureInfo.InvariantCulture);
string year = DateTime.Now.ToString("yy");

goodsReceipt.Lines.BatchNumbers.SetCurrentLine(0);
goodsReceipt.Lines.BatchNumbers.BatchNumber = monthName + year + giDocNum.ToString().PadLeft(5, '0') + "1";
goodsReceipt.Lines.BatchNumbers.Quantity = (Convert.ToDouble(EditText3.Value) - Convert.ToDouble(EditText6.Value)) / 2;
goodsReceipt.Lines.BatchNumbers.Add();

goodsReceipt.Lines.SetCurrentLine(0);
goodsReceipt.Lines.ItemCode = ComboBox2.Value;
goodsReceipt.Lines.AccountCode = wipCredit;
goodsReceipt.Lines.Quantity = (Convert.ToDouble(EditText3.Value) - Convert.ToDouble(EditText6.Value)) / 2;
goodsReceipt.Lines.UnitPrice = convertedPrice;
goodsReceipt.Lines.WarehouseCode = ComboBox3.Value;
goodsReceipt.Lines.CostingCode = unit;
goodsReceipt.Lines.CostingCode2 = prcCode;
goodsReceipt.Lines.Add();

goodsReceipt.Lines.BatchNumbers.SetCurrentLine(1);
goodsReceipt.Lines.BatchNumbers.BatchNumber = monthName + year + giDocNum.ToString().PadLeft(5, '0') + "2";
goodsReceipt.Lines.BatchNumbers.Quantity = (Convert.ToDouble(EditText3.Value) - Convert.ToDouble(EditText6.Value)) / 2;
goodsReceipt.Lines.BatchNumbers.Add();

goodsReceipt.Lines.SetCurrentLine(1);
goodsReceipt.Lines.ItemCode = ComboBox2.Value;
goodsReceipt.Lines.AccountCode = wipCredit;
goodsReceipt.Lines.Quantity = (Convert.ToDouble(EditText3.Value) - Convert.ToDouble(EditText6.Value)) / 2;
goodsReceipt.Lines.UnitPrice = convertedPrice;
goodsReceipt.Lines.WarehouseCode = ComboBox3.Value;
goodsReceipt.Lines.CostingCode = unit;
goodsReceipt.Lines.CostingCode2 = prcCode;
goodsReceipt.Lines.Add();int lRetCode2 = goodsReceipt.Add();

if (lRetCode2 != 0)
{

Regards,

 

 

Accepted Solutions (0)

Answers (0)