Skip to Content
0
Former Member
Sep 22, 2008 at 09:39 AM

Batch generation through DI API

1461 Views

Hi All,

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,

Binita