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

DI: Add Serialnumbers to AR Invoice Lines

We are having a difficult time adding serialized items to AR invoices through the DI. It doesn't seem to be happy doing this no matter what we try. Probably a rookie mistake but I have tried several different ways of doing this with no luck. We get a 5002 error when trying to add the invoice if the serialized items are included on it. Works fine with just the non-serialized.

Here is the current iteration of the code. The DB lookups work fine and return the desired values. The exact same serialized items can manually be added to an invoice without any issues. If anyone can offer some advice I would greatly appreciate it.

Thanks,

Matt

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

Dim EINV As SAPbobsCOM.Documents

Dim SerialNumber As SAPbobsCOM.SerialNumbers

Set EINV = Company.GetBusinessObject(oInvoices)

'Snip

'EINV setup and non-serialized items added

'No problems until we try adding serialized items

'All values return properly and can be added manually to an invoice.

'Fails with a 5002 when EINV.Add is invoked after serialized items are added.

'EINV.Add works fine with serialized code disabled.

If SerialRS.RecordCount > 0 Then

SerialRS.MoveFirst

Do While SerialRS.EOF = False

STech = SerialRS.Fields("TechNumber").Value

SItemID = SerialRS.Fields("ItemID").Value

SSerial = SerialRS.Fields("Serial").Value

If STech = TechNo Then

EINV.Lines.Add

EINV.Lines.SetCurrentLine (EINV.Lines.Count - 1)

EINV.Lines.ItemCode = RTrim(SItemID)

EINV.Lines.Quantity = 1

EINV.Lines.TaxCode = "ZERO"

EINV.Lines.WarehouseCode = TechNo

Set SerialNumber = EINV.Lines.SerialNumbers

SerialNumber.SetCurrentLine (SerialNumber.Count - 1)

Set RecSet3 = Company.GetBusinessObject(BoRecordset)

RecSet3.DoQuery ("select top 1 sysserial from osri where intrserial = '" & SSerial & "'")

If RecSet3.RecordCount > 0 Then

SerialNumber.InternalSerialNumber = SSerial

SerialNumber.SystemSerialNumber = RecSet3.Fields("sysserial").Value

End If

End If

SerialRS.MoveNext

Loop

End if

Addresult = EINV.Add

If (Addresult <> 0) Then

Call Company.GetLastError(nErr, errMsg)

If (0 <> nErr) Then

MsgBox ("Found error:" + Str(nErr) + "," + errMsg)

End If

End If

Add a comment
10|10000 characters needed characters exceeded

Related questions

1 Answer

  • author's profile photo Former Member
    Former Member
    Posted on Dec 14, 2004 at 07:11 PM

    This is evidently an issue with adding non-serialized items to an invoice before adding serialized items through the DI. It looks like the DI was trying to add the serialnumbers to the non-serialized doclines despite our best efforts to add them to the appropriate items. Once we changed the order of our code and added the serialized items first it worked just fine.

    On a related note, if you add individual lines to an invoice for the same item (multiple lines of single quantity for the same item instead of a single line with a quantity > 1) the DI will only add serialnumbers to the first docline occurence of the item in question.

    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.