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 comment
10|10000 characters needed characters exceeded

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 comment
    10|10000 characters needed characters exceeded