Skip to Content
Former Member
Oct 29, 2012 at 10:06 AM

Add serial number for Goods Return


Hye expert,

i'm new in developing SAP Data Interface.

How to add serial number in OSRI table?

i need to do this step because the application need to add new entry for good return into the SAP.

Last time when the item is sold, the user still not yet using SAP.

So when there are goods return, my application cannot find the serial number in SAP system.

If do manually in SAP GUI, i have no problem in adding them because a window will shown and i can define new serial to the item.

But how to do it in Data Interface?

here is my code.

'On top here find the serial in OSRI table (Recset3)

' if the serial found in the OSRI

If RecSet3.RecordCount > 0 Then

While Not RecSet3.EoF

RecSet4 = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset)

RecSet4.DoQuery("SELECT IntrSerial, SysSerial FROM OSRI(nolock) WHERE ItemCode='" & RecSet.Fields.Item("U_DocItem").Value & "' AND IntrSerial='" & RecSet3.Fields.Item("U_DocSerial").Value & "'")

'check for itemcode and intrserial in OSRI

If RecSet4.Fields.Item("IntrSerial").Value <> "" Then

oDoc.Lines.SerialNumbers.SystemSerialNumber = RecSet4.Fields.Item("SysSerial").Value

oDoc.Lines.SerialNumbers.InternalSerialNumber = RecSet3.Fields.Item("U_DocSerial").Value


End If


End While

'if not found in OSRI. here i stuck. i want to force the application to add new entry in goods return, plus add the serial in OSRI. here is my 'attempt to do it but fail.


oDoc.CardCode = "L8A111117153633"

oDoc.DocDate = CDate(Now)

oDoc.DocDueDate = CDate(Now)

oDoc.Lines.ItemCode = "SMC6022"

oDoc.Lines.Quantity = 1

oDoc.Lines.Price = 777

'loop only one time. for testing only.

For i As Integer = 1 To 1

oDoc.Lines.SerialNumbers.SetCurrentLine(i - 1)

oDoc.Lines.SerialNumbers.InternalSerialNumber = RecSet3.Fields.Item("U_DocSerial").Value

'oDoc.Lines.SerialNumbers.SystemSerialNumber = 568 'currently 567 is the highest number under SysSerial 'column



Dim qq As Long

Dim aa As Long

Dim zz As String

qq = oDoc.Add()

if qq <> 0 Then

oCompany.GetLastError(aa, zz)


End If

End If

The error is 'You should use existing serial/batch numbers for this document type [(----) 29-51]'

i have search the discussion lounge but i cannot found the answer i looking for.

I really hope someone can help me.

Thank You