Showing results for 
Search instead for 
Did you mean: 

DIAPI posting Delivery Document with Serial Numbers

Former Member
0 Kudos


I am using SAP 2005A, SP01, Patch 8. I am not able to create a delivery document based on Sales Order with serial number items.

Code is given below. The error i get is

Error No: -10, Message: [DLN1.WhsCode][line: 0] , 'The selected quantity of batch/serial numbers is greater than the open quantity.'

When i checked the openqty in the sales order it is 0 and i guess we cannot set it thru DIAPI. Any solutions?

Dim oSO As SAPbobsCOM.Documents

Dim oDlv As SAPbobsCOM.Documents

oSO = pcompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oOrders)

oDlv = pcompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oDeliveryNotes)

' iSoDocEntry contains Sales Order no

If oSO.GetByKey(iSoDocEntry) = True Then

oDlv.CardCode = oSO.CardCode

oDlv.DocDueDate = oSO.DocDueDate

oDlv.Comments = "Based on Sales Order " & iSoDocEntry & "." & oSO.Comments

oDlv.Address = oSO.Address

oDlv.ShipToCode = oSO.ShipToCode

oDlv.Address2 = oSO.Address2

oDlv.AgentCode = oSO.AgentCode

oDlv.DocType = SAPbobsCOM.BoDocumentTypes.dDocument_Items

oDlv.DocumentSubType = SAPbobsCOM.BoDocumentSubType.bod_None

oDlv.Lines.BaseLine = iRowNo

oDlv.Lines.BaseType = SAPbobsCOM.BoAPARDocumentTypes.bodt_Order

oDlv.Lines.BaseEntry = iSoDocEntry

Dim objSerialNum As SAPbobsCOM.SerialNumbers

Dim sSerialNumbers(), sSysSerialNumbers(), sInternalSerial() As String

Dim iCount As Integer

objSerialNum = oDlv.Lines.SerialNumbers()

sSerialNumbers = sSupSerial.Split(",") ' Contains the List of Supplier Serial Nos value of the Selected serials

sSysSerialNumbers = sSysserial.Split(",") ' Contains the List of Sys Serial value of the selected serials

sInternalSerial = sInternal.Split(",") ' Contains the List of Internal Serial value of the selected serials

For iCount = 0 To sSysSerialNumbers.Length() - 1

objSerialNum.InternalSerialNumber = sInternalSerial.GetValue(iCount)

objSerialNum.ManufacturerSerialNumber = sSerialNumbers.GetValue(iCount)

objSerialNum.SystemSerialNumber = sSysSerialNumbers.GetValue(iCount)




end if

iReturnValue = oDlv.Add()



Accepted Solutions (1)

Accepted Solutions (1)

Active Contributor
0 Kudos

Hi Jayakumar,

Thank you very much for posting your code!

Could the issue be that for oDlv.Lines.SerialNumbers()

you have to call Add() one time less than you have Serial Numbers?

This is true for the oDlv.Lines as you know, but isn't it the same for the SerialNumbers()?



Former Member
0 Kudos


I was having the same problem... With that error though I found that when I wrote the Delivery Obj to an XML file that every time that you add a Serial Number Line you are adding a blank Serial number line, and thus producing that error. I have also seen other post the same problem with the same solution of removing the Add completely for all serial numbers. Just a warning as well. If you want to create a Delivery Withless items then the assosiated SO, There seems to be a bug with SAP that will give you a error stating that some random Item (one that may or may not be in the sales order) does not have a system Serial number avaliable...

Anyways, that has been my experience,

Hope this helps

Jeremy Adam

Former Member
0 Kudos

Hi Frank,

I tried doing the add one time less than the number of serial numbers. I am getting the same error. Am I missing any other thing?



Former Member
0 Kudos


Read my earlier post or you can try here:

Jeremy Adam

Former Member
0 Kudos

Thanks Jeremy..

It worked.


Answers (0)