Batch generation through DI API
I want to generate batches for items that are managed by batch with option 'On release only'. (something equivalent to using Inventory -- Item Management ---Batches -- Batch Management option in SAP UI).
this option also provides selection for the object or type of document for creation of batch (like Purchase, Sales, Stock posting). I just want to create batches with DI API for the items posted with Goods Receipt . but could not do it with the following code. I have hardcoded some values.
Dim orec As SAPbobsCOM.Documents orec = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oInventoryGenEntry) If orec.GetByKey("29") = True Then For i = 0 To orec.Lines.Count - 1 orec.Lines.SetCurrentLine(i) orec.Lines.BatchNumbers.BatchNumber = "batch01" & i orec.Lines.BatchNumbers.Quantity = orec.Lines.Quantity orec.Lines.BatchNumbers.BaseLineNumber = i orec.Lines.BatchNumbers.Add() Next RetVal = orec.Update If RetVal <> 0 Then oCompany.GetLastError(ErrCode, ErrMsg) MsgBox(ErrMsg) End If End If
the code does not throw any error. nor does it add the batch to OIBT table.
what could be wrong in this?
or is there any way to do batch creation other than this?
thanks and regards,
It is not possible to add batches in this way to the goods receipt once it has been created via the DI API. As far as I can tell, it is also not possible in the application - to add batch numbers for an item that has entered through a goods receipt, you can not do it on the document, but must do it through the "Complete Batches" functionality.
Additionally, the "Complete Batches" functionality of the application you described is currently not exposed to the DI API so it would not be possible to implement this in your solution.
I'm sorry I couldn't be more helpful,
SAP Business One Forums.