Inventory Receipt (COM)
References |
|
|
|
To Use the Inventory Receipt the following references need to be added to your project · WiSys.AllSystem · WiSys.ImTrx
|
|
|
|
Source Code |
|
Sub InventoryReceipt()
On Error GoTo ErrorHandler
'Dim the three WiSys Objects for the Inv Issue and S/L/Bin and then 'the Connection Object. The ItemBinReceipt object is used for 'Issues and Reciepts Dim oReceipt As New Wisys_ImTrx_v3_0.Receipt Dim oBins As New ItemBins Dim oBin As ItemBin Dim oSerialLot As ItemSerialLot Dim iRtnVal As Integer Dim sRtnErrMsg As String Dim oConn As New ConnectionInfo 'The Connection Object creates several connections 'One obviously to the database but also to Maclocks to handle all 'locking as well as transaction control 'Two connection parameter options are available 'The first one passes full authentication which is used for the 'complete set of transactions. 'The second uses the authentication of the WiSys setup for 'Web Services
oConn.Parameters "(local)", "001", “MacMSS”
' Not required but you can test the connection If oConn.TestConnectivity(sRtnErrMsg) = False Then MsgBox "Failed to connect. " & sRtnErrMsg, vbOKOnly Exit Sub End If 'Open the transaction iRtnVal = oConn.OpenWisysConnection(True, sRtnErrMsg) If iRtnVal <> 0 Then MsgBox "Failed " & sRtnErrMsg, vbOKOnly Exit Sub End If 'Set all of the Issue Object Parameters as you would see them in 'the Inventory Transaction Screen With oReceipt .UserName = “SUPERVISOR” .DocumentDate = Now() .DocumentSource = DocumentSource_CustomerOrder .Customer = “901” .DocOrderNo = “” .ItemNumber = “HORN” .Location = “MA” .Quantity = 20 .Comment1 = "Comment 1" .Comment2 = "Comment 2" .Connection oConn 'Add Bin 200 and both lots Set oBin = oBins.Add(”200”, 10) Set oSerialLot = oBin.SerialLotNumbers.Add(“KL2002000000055”, 5) oSerialLot.MfgSerialLotNumber = “MFG1234567890” oSerialLot.EffectiveDate = Now() oSerialLot.ExpirationDate = DateAdd("YYYY", 15, Now()) Set oSerialLot = oBin.SerialLotNumbers.Add(“KL2002000000056”, 5) oSerialLot.MfgSerialLotNumber = “MFG1234567891” oSerialLot.EffectiveDate = Now() oSerialLot.ExpirationDate = DateAdd("YYYY", 15, Now()) 'Add Bin 100 and both lots Set oBin = oBins.Add(“100”,10) Set oSerialLot = oBin.SerialLotNumbers.Add(“KL2002000000057”,5) oSerialLot.MfgSerialLotNumber = “MFG1234567892” oSerialLot.EffectiveDate = Now() oSerialLot.ExpirationDate = DateAdd("YYYY", 15, Now()) Set oSerialLot = oBin.SerialLotNumbers.Add(“KL2002000000058”, 5) oSerialLot.MfgSerialLotNumber = “MFG1234567893” oSerialLot.EffectiveDate = Now() oSerialLot.ExpirationDate = DateAdd("YYYY", 15, Now()) 'Set Receipt Trx to Bin object collection Set .RecieptBins = oBins 'Call the Transation and return an error code 'and error message string iRtnVal = .PostTrx(sRtnErrMsg) End With
If iRtnVal = 0 Then 'If error code ok then commit the transaction. You can call 'multiple transactions prior to the commit and continue 'to generate Maclocks and maintain the same transaction iRtnVal = oConn.CloseWisysConnection(TransactionAction.TransactionAction_Commit, sRtnErrMsg) If iRtnVal = 0 Then MsgBox "Worked " & sRtnErrMsg, vbOKOnly Else MsgBox "Failed " & sRtnErrMsg, vbOKOnly End If Else MsgBox "Failed " & sRtnErrMsg, vbOKOnly 'If error code not ok then roll back the transaction 'The transaction will stay open until you commit it or roll it 'back or terminate your application. It was decided to give the 'the developer full control over the transaction iRtnVal = oConn.CloseWisysConnection(TransactionAction.TransactionAction_Rollback, sRtnErrMsg) End If Exit Sub ' Exit to avoid handler. ErrorHandler: iRtnVal = _ oConn.CloseWisysConnection(TransactionAction.TransactionAction_Rollback, sRtnErrMsg) MsgBox "Failed " & sRtnErrMsg, vbOKOnly
End Sub
|