Skip to Content
avatar image
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

oDraft.DocObjectCode=SAPbobsCOM.BoObjectTypes.oDeliveryNotes

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

  • Follow
  • Get RSS Feed

1 Answer

  • avatar image
    Former Member
    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)

    'Header

    vDraft.CardCode = "C30009"

    vDraft.DocObjectCode = oInvoices

    'Lines

    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

    Cheers,

    Lisa Mulchinock

    SDK Support Consultant

    Galway

    Add comment
    10|10000 characters needed characters exceeded