Dear Experts,
I have a problem when I want to create DI Inventory transfer. Below is the detail about what I face:
In this case, RM warehouse has 1 bin location (BIN001),
BIN001 has 2 batch as below :
BATCH01 -- 1500 boxes
BATCH02 -- 1000 boxes
For example, I have item A which will be transfered from RM warehouse to PRD warehouse with quantity 2000 boxes.
Based on the information above, the stock which should be transfered from RM warehouse is as below :
BIN001 BATCH01 -- 1500 boxes
BIN001 BATCH02 -- 500 boxes.
The things that I want is it can automatically calculate and choose which BIN and BATCH should be taken for this inventory transfer.
I have created some code to solve this DI but I got a problem about the looping process to check which BIN I should take.
Please put any comment and suggestion about my below code and thank you for the help.
Dim oOWTR As SAPbobsCOM.StockTransfer
oOWTR = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oStockTransfer)
Dim SBO As SBOAdapter
Dim tgadapter As New TransferGudangAdapter
oOWTR.DocDate = DateTime.Now
oOWTR.FromWarehouse = "RM"
oOWTR.ToWarehouse = "PRD"
oOWTR.Comments = "RM to PRD"
oOWTR.JournalMemo = "Inventory Transfer - " & ID
For Each WOR1 In t_tit
v_transIT = tgadapter.get_vIT2(WOR1.Itemcode, WOR1.Bin, ID).First
oOWTR.Lines.ItemCode = WOR1.Itemcode
oOWTR.Lines.FromWarehouseCode = "RM"
oOWTR.Lines.WarehouseCode = "PRD"
oOWTR.Lines.Quantity = v_transIT.qty
Dim qtytemp As Integer
Dim onhandqtytemp As Integer
Dim v_transIT3 As String
qtytemp = WOR1.Qty
onhandqtytemp = v_transIT.onhandqty
oOWTR.Lines.BatchNumbers.SetCurrentLine(0)
oOWTR.Lines.BatchNumbers.BatchNumber = v_transIT.batchabsentry
oOWTR.Lines.BatchNumbers.Quantity = v_transIT.qty
oOWTR.Lines.BatchNumbers.Add()
oOWTR.Lines.BinAllocations.SetCurrentLine(0)
oOWTR.Lines.BinAllocations.SerialAndBatchNumbersBaseLine = 0
oOWTR.Lines.BinAllocations.BinActionType = 2
oOWTR.Lines.BinAllocations.BinAbsEntry = v_transIT.binabs
oOWTR.Lines.BinAllocations.Quantity = v_transIT.qty
oOWTR.Lines.BinAllocations.Add()
oOWTR.Lines.Add()
Next