cancel
Showing results for 
Search instead for 
Did you mean: 

Invoice

Former Member
0 Kudos

Hi Experts,

I need to create invoice after the delivery is created through DIAPI. Could you please give me an idea how to do the same through a sample code .

Thanks and Regards,

Kreddy

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Kreddy,

Here's some sample code of how to convert a delivery note(object type 15) to a sales invoice.

'Firstly you would get the number of the delivery note.

Dim oDeliveryNote As SAPbobsCOM.Documents

Dim sDocEntry As Integer

'your code where you set delivery note properties goes here

If oDeliveryNote.Add() = 0 then

sDocNum = oCompany.GetNewObjectCode

Else

oApplication.MessageBox("Error: " & oCompany.GetLastErrorDescription)

Exit Sub

End If

'Then you would add the invoice based on the delivery note just added

Dim oInvoice As SAPbobsCOM.Documents

Dim i As Integer

oDeliveryNote = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oDeliveryNotes)

oInvoice = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oInvoices)

oDeliveryNote.GetByKey(sDocEntry)

oInvoice.CardCode = oDeliveryNote.CardCode

oInvoice.CardName = oDeliveryNote.CardName

oInvoice.Address = oDeliveryNote.Address

oInvoice.DocDate = oDeliveryNote.DocDate

oInvoice.DocDueDate = oDeliveryNote.DocDate

For i = 0 To oDeliveryNote.Lines.Count - 1

oDeliveryNote.Lines.SetCurrentLine(i)

If i > 0 Then

oInvoice.Lines.Add()

End If

oInvoice.Lines.BaseEntry = oDeliveryNote.DocEntry

oInvoice.Lines.BaseLine = oDeliveryNote.Lines.LineNum

oInvoice.Lines.BaseType = 17

Next

If oInvoice.Add() 0 Then

oApplication.MessageBox("Error: " & oCompany.GetLastErrorDescription)

End If

Hope it helps,

Adele

Former Member
0 Kudos

that was helpful! thanks a lot!

Answers (1)

Answers (1)

Former Member
0 Kudos

My question about this is that

There's a lot of fields in the header. Do we have to copy all of them manualy like that ?

ShipToCode ?

PayToCode ?

Everything about the accounting ?

There's no way to base the Invoice on the delivery with just one property ?

For the Lines its all right its a fair way to do it but for all the other fields do we have to bring them all one by one like you wrote above for the header ?