Hi All,
I have a requirement to convert deliveries to invoice through code.
When adding a delivery without rearranging items in the matrix and converting that delivery to invoice through code works fine.This can be done using the "Copy To" function in delivery window also.However when I add items to a new delivery , eg : items A001,A002,A003 added to the lines and before clicking the add button, I changed A001 to A003,Then clicked add.Delivery is saved.This saved delivery couldnt be converted to Invoice through code.Error is "INV1: ItemCode is missing in Line".But this delivery can be manually converted to invoice though B1 window.The code I am using is as follows.
SAPbobsCOM.Documents oINV;
oINV = (SAPbobsCOM.Documents)
modups.oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oInvoices);
oINV.CardCode = oDLN.CardCode;
for (int i = 0; i < oDLN.Lines.Count; i++)
{
oDLN.Lines.SetCurrentLine(i);
string str = oDLN.Lines.ItemCode;
if (i != 0)
{
oINV.Lines.Add();
}
oINV.Lines.BaseType = Convert.ToInt32(SAPbobsCOM.BoObjectTypes.oDeliveryNotes);
oINV.Lines.BaseEntry = oDLN.DocEntry;
oINV.Lines.BaseLine = i;
taxcode = oDLN.Lines.TaxCode;
}
oINV.Add();
Can any body help me to trouble shoot this? I am wondering because it works in one case and fails in othercase where the itemcode is edited just before save.
Deepesh