Skip to Content
0
Mar 19, 2009 at 12:30 PM

Bug in DI ? When changing order price

32 Views

Hi!

I'm changing price in 8000 open order documents. It works fine for 2500 of them but for the rest i get the error "There is a difference between the document total and its components".

Roughly, the code look like this:

 doc = (SAPbobsCOM.Documents)comp.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oOrders); 
if (!doc.GetByKey(docEntry))
throw new ApplicationException("DocNum " + docNum.ToString() + ": " + addOn.sapCompany.GetLastErrorCode().ToString() + ": " + addOn.sapCompany.GetLastErrorDescription());
              else
                Debug.WriteLine(doc.DocNum.ToString() + ": Num lines = " + doc.Lines.Count.ToString() + ", DocTotal = " + doc.DocTotal.ToString("0.00"));
            }

// update the current line

for (int i = 0; i < doc.Lines.Count; i++)

{

doc.Lines.SetCurrentLine(i);

if (doc.Lines.LineNum == lineNum)

break;

}

if (doc.Lines.LineNum != lineNum)

throw new ApplicationException("DocNum " + docNum.ToString() + ": Cannot find LineNum " + lineNum.ToString() + ": " + addOn.sapCompany.GetLastErrorDescription());

if ((listNum == 12) && (itemCode == "304001") && (Math.Round(price) == 280.0))

;

else

{

Debug.WriteLine(" line " + doc.Lines.LineNum.ToString() + ": current price = " + doc.Lines.Price.ToString("0.00") + ", UnitPrice = " + doc.Lines.UnitPrice.ToString("0.00") + ", LineTotal = " + doc.Lines.LineTotal.ToString("0.00") + ", TaxTotal = " + doc.Lines.TaxTotal.ToString("0.00") + ", total = " + (doc.Lines.LineTotal + doc.Lines.TaxTotal).ToString("0.00"));

doc.Lines.UnitPrice = newPrice;

doc.Lines.Price = newPrice;

docChanged = true;

numChangedDocLines++;

}