Creating an Order, adding a batch.. How do I do this?
I am wondering if you could please help me understand how to add a batch to an order with DIAPI?
We are wanting to add, update, and delete batches, but I am not yet seeing how to do it.
sorry for the late reply.
this is the code you want. I have hardcoded the values.
Dim orec As SAPbobsCOM.Documents Dim oitem As SAPbobsCOM.Items oitem = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oItems) orec = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oOrders) orec.DocDate = Today.Date orec.DocDueDate = Today.Date orec.CardCode = "C00001" orec.Lines.ItemCode = "BAevrytrans" orec.Lines.Quantity = 3.5 orec.Lines.WarehouseCode = "01" orec.Lines.UnitPrice = 33 If oitem.GetByKey("BAevrytrans") = True Then If oitem.ManageBatchNumbers = SAPbobsCOM.BoYesNoEnum.tYES And oitem.SRIAndBatchManageMethod = SAPbobsCOM.BoManageMethod.bomm_OnEveryTransaction Then orec.Lines.BatchNumbers.BatchNumber = "090800000013" 'the batch should exist in system orec.Lines.BatchNumbers.Quantity = 3.5 End If End If 'if you want to add more items, write 'orec.Lines.Add RetVal = orec.Add If RetVal <> 0 Then oCompany.GetLastError(ErrCode, ErrMsg) MsgBox(ErrMsg) End If
this will create the order as well as batches.
hope that helps,