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

Trying to create a Invoice based on Order need help Error -5002

the dreaded -5002 error is haunting me too! and I could not find a matching solution for this in the forum....

I need help quickly on this. I am trying to create invoices for some orders so the Base - Target relationship is retained. The orders I pick are all Open (DocStatus = O and the lines are all Open LineStatus = O)

here is my code

oInvoice.Lines.BaseEntry = 48
oInvoice.Lines.BaseLine = 0
oInvoice.Lines.BaseType = SAPbobsCOM.BoObjectTypes.oOrders
oInvoice.Lines.ItemCode = "A00001"
oInvoice.Lines.ItemDescription = "IBM Infoprint 1312"

'-----------------------------------
'adding Line
'-----------------------------------
oInvoice.Lines.Add

oInvoice.Lines.BaseEntry = 48
oInvoice.Lines.BaseLine = 1
oInvoice.Lines.BaseType = SAPbobsCOM.BoObjectTypes.oOrders
oInvoice.Lines.ItemCode = "A00002"
oInvoice.Lines.ItemDescription = "IBM Inforprint 1222"
           
'-----------------------------------
'adding Line
'-----------------------------------
oInvoice.Lines.Add

lRetCode = oInvoice.Add

If lRetCode <> 0 Then
    gObjCompany.GetLastError lErrCode, sErrMsg
    MsgBox (lErrCode & " " & sErrMsg)
End If

Add a comment
10|10000 characters needed characters exceeded

Related questions

2 Answers

  • Best Answer
    Posted on Jul 27, 2005 at 07:16 AM

    Indika,

    Only set your base types...

    (not items & description)

    ***********************

    oInvoice.Lines.BaseEntry = 48

    oInvoice.Lines.BaseLine = 0

    oInvoice.Lines.BaseType = SAPbobsCOM.BoObjectTypes.oOrders

    oInvoice.Lines.ItemCode = "A00001"

    oInvoice.Lines.ItemDescription = "IBM Infoprint 1312"

    '----


    'adding Line (to fill the second item line)

    ' the 1st line item is there by default

    '----


    oInvoice.Lines.Add

    oInvoice.Lines.BaseEntry = 48

    oInvoice.Lines.BaseLine = 1

    oInvoice.Lines.BaseType = SAPbobsCOM.BoObjectTypes.oOrders

    oInvoice.Lines.ItemCode = "A00002"

    oInvoice.Lines.ItemDescription = "IBM Inforprint 1222"

    '----


    'DO NOT Add THIS line

    ' (only if you want to add a 3rd line item)

    '----


    '''oInvoice.Lines.Add -> Don't add this

    lRetCode = oInvoice.Add

    If lRetCode <> 0 Then

    gObjCompany.GetLastError lErrCode, sErrMsg

    MsgBox (lErrCode & " " & sErrMsg)

    End If

    ****************

    remember to add :

    oInvoice.CardCode = "your BP"

    oInvoice.DocDueDate = Now

    oInvoiceDoc.CardCode = txtDOCBPCode.Text

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jul 27, 2005 at 07:07 AM

    Hi,

    i don't know exactly this error code (probably the error message can help me), but i'm not seeing the oInvoce.Lines.AccountCode property setting... for my knowledge this is a mandatory field for "document lines objects"

    Hope this helps.

    Kind regards,

    Fabio Salucci

    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.