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

Add method for a draft document

Hi there

When I try to add a draft document, the getLastError method return a -5002 error, but the message with this message "-".

The properties of the draft object that i'm filling are:

oDraft.DocObjectCode = SAPbobsCOM.BoObjectTypes.oPurchaseDeliveryNotes (to make it a draft of a purchase delivery note)

oDraft.Series = 0

oDraft.CardCode = oPurchaseOrder.CardCode

oDraft.HandWritten = SAPbobsCOM.BoYesNoEnum.tNO

oDraft.PaymentGroupCode = oPurchaseOrder.PaymentGroupCode

oDraft.DocDate = Now

oDraft.TaxDate = oPurchaseOrder.TaxDate

and for the lines i'm filling:

oDraft.Lines.ItemCode = detailLine.itemCode

oDraft.Lines.Quantity = detailLine.quantity

detailLine is an object of my own that contains the information that i'm going to add.

I use this same properties to create a draft document but with the property


and I have no problems.

My question is, do i have to fill another property?, Am I doing something wrong?

I thank your help

Add a comment
10|10000 characters needed characters exceeded

Related questions

1 Answer

  • author's profile photo Former Member
    Former Member
    Posted on Jun 30, 2004 at 07:20 AM

    Hello Cesar,

    I have included below some code necessary to add a draft document. The most important points is to set the draft object and later set DocObjectCode to the document type you want to save as draft.

    I hope it will assit you:

    Private Sub CmdAddDraft_Click()

    Dim retval, ErrCode As Long

    Dim ErrMsg As String

    Dim vDraft As SAPbobsCOM.Documents

    Set vDraft = vCmp.GetBusinessObject(oDrafts)


    vDraft.CardCode = "C30009"

    vDraft.DocObjectCode = oInvoices


    vDraft.Lines.ItemCode = "A00003"

    vDraft.Lines.Quantity = 2

    vDraft.Lines.VatGroup = "NY"

    retval = vDraft.Add

    If retval <> 0 Then

    vCmp.GetLastError ErrCode, ErrMsg

    MsgBox ErrCode & " " & ErrMsg

    End If

    End Sub


    Lisa Mulchinock

    SDK Support Consultant


    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.