Skip to Content
0
Former Member
Jun 22, 2006 at 07:46 AM

Stock Transfers with Serial Numbers

456 Views

Hi there, Please help! I am trying to create a stock transfer with serial numbers but when i assign the serial number to the InternalSerialNumber property of the Serial Numbers object within the Stock Transfer object I am getting an error saying that the serial umber is zero and does not exist in the warehouse. Here is a segment of my code in VB :

'declare stock transfer object

Dim oST As SAPbobsCOM.StockTransfer

'string to store the new object code

Dim OrdCodeStr As String

'instantiate a Stock Transfer object

oST = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oStockTransfer)

'set the documents date

oST.DocDate = "05/06/06"

'set the originating warehouse number

oST.FromWarehouse = "01"

'set the serial number sup on the SN object in the Stock Transfer Lines object

'item code and warehouse code are mandatory

'item A1000 is managed by serial numbers on every transaction

'add the first line

oST.Lines.ItemCode = "A1000"

oST.Lines.WarehouseCode = "02"

'serial number hardcoded here but must exist in the warehouse 01 for item A1000

oST.Lines.SerialNumbers.InternalSerialNumber = "abc210"

oST.Lines.Quantity = 1

oST.Lines.SerialNumbers.Add()

'add the second

oST.Lines.Add()

oST.Lines.ItemCode = "A1000"

oST.Lines.WarehouseCode = "02"

'serial number hardcoded here but must exist in the warehouse 01 for item A1000

oST.Lines.SerialNumbers.InternalSerialNumber = "abc211"

oST.Lines.Quantity = 1

oST.Lines.SerialNumbers.Add()

'add the third

oST.Lines.Add()

oST.Lines.ItemCode = "A1000"

oST.Lines.WarehouseCode = "02"

'serial number hardcoded here but must exist in the warehouse 01 for item A1000

oST.Lines.SerialNumbers.InternalSerialNumber = "abc212"

oST.Lines.Quantity = 1

oST.Lines.SerialNumbers.Add()

'Add the stock transfer

lRetCode = oST.Add

'Check return Code

If lRetCode <> 0 Then

oCompany.GetLastError(lErrCode, sErrMsg)

MsgBox("Error : " & lErrCode & " : " & sErrMsg)

Else

'Gets the most recently created Object (Order) Code

'Stores that code in the String 'OrdCodeStr'

oCompany.GetNewObjectCode(OrdCodeStr)

MsgBox(" Added Stock Transfer No. : " & OrdCodeStr)

End If

...

If anyone can help me out that would be great!

Thanks,

Greeshma