Skip to Content
0
Former Member
Nov 29, 2006 at 05:31 PM

Adding Lines to a Sales Order

49 Views

Hello !

I'm using the following code (pretty much) to add items to existing sales orders :

Dim oOrder As SAPbobsCOM.Documents
oOrder = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oOrders)
oOrder.GetByKey(id)
oOrder.Lines.Add()
oOrder.Lines.ItemCode = newItemCode
oOrder.Lines.Quantity = newQuantity
oOrder.Lines.UserFields.Fields.Item("U_S_Desc").Value = newItemDesc
lretcode = oOrder.Update

This works fine for most nearly all of the orders that are processed, however for some of the orders I get the error : No matching Records Found (ODBC -2028).

I know the record I'm looking for exists, and if Open up the order and add the data manually it works, but something just seems to be stopping the code from doing it.

I think it might be something to do with the Order's date, but exactly what I don't know.

I was wondering if anyone's come across something like this before, of if there's an obvious reason why it wouldn't write ?