Skip to Content
author's profile photo Former Member
Former Member

Invoice

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

Add a comment
10|10000 characters needed characters exceeded

Related questions

2 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Dec 26, 2007 at 08:05 AM

    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

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 10, 2008 at 05:13 PM

    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 ?

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.