Skip to Content
Former Member
Jul 26, 2005 at 06:01 AM

Creating a Delivery Note From Sales Orders



We are trying to create a Deliery note for a SO using DI API. We are using SAP 2004A and creating the Addon using VB.NET

If the SO has a single line then the deliver note gets created properly. When the SO has multiple line items then the following error occurs "target item code mismatch base itemcode [odln.doctype]".

Can some one help me on this.

Thanks in Advance Ganesh.

This is the code that i use to create the Delivery note

vSO = pCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oOrders)

If vSO.GetByKey(sSO) Then

vDelivery = pCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oDeliveryNotes)

vDelivery.CardCode = vSO.CardCode

vDelivery.SalesPersonCode = vSO.SalesPersonCode

vDelivery.DocType = SAPbobsCOM.BoDocumentTypes.dDocument_Items

vDelivery.DocumentSubType = SAPbobsCOM.BoDocumentSubType.bod_None

vDelivery.Address = vSO.Address

vDelivery.ShipToCode = vSO.ShipToCode

vDelivery.Address2 = vSO.Address2

vDelivery.HandWritten = SAPbobsCOM.BoYesNoEnum.tNO

vDelivery.JournalMemo = "Delivery - " &vSO.CardCode

vDelivery.Comments = "Based on SO " & sSO

vDelivery.PaymentGroupCode = vSO.PaymentGroupCode

vSOLines = vSO.Lines

vDeliveryLines = vDelivery.Lines

Dim iCnt As Integer

For iCnt = 0 To vSOLines.Count - 1


vDeliveryLines.ItemCode = vSOLines.ItemCode

vDeliveryLines.Quantity = vSOLines.Quantity

vDeliveryLines.Rate = vSOLines.Rate

vDeliveryLines.BaseType = SAPbobsCOM.BoAPARDocumentTypes.bodt_Order

vDeliveryLines.BaseEntry = sSO



lRetCode = vDelivery.Add()

If lRetCode <> 0 Then

Dim sErr As String

pCompany.GetLastError(lRetCode, sErr)


End If

End If