cancel
Showing results for 
Search instead for 
Did you mean: 

Inventory Transfer - Bin Allocation

Former Member
0 Kudos

Hi Team,

How to assign batch/serial in bin location for inventory transfer (From Bin Location , To Bin Location ). Is it similiar in below

sample code

   transfer.Lines.BinAllocations.SetCurrentLine(0);
                transfer.Lines.BinAllocations.BinActionType = SAPbobsCOM.BinActionTypeEnum.batFromWarehouse;
                transfer.Lines.BinAllocations.BinAbsEntry = fromLocation;
                transfer.Lines.BinAllocations.Quantity = quantity;
                transfer.Lines.BinAllocations.Add();

                transfer.Lines.BinAllocations.SetCurrentLine(0);
                transfer.Lines.BinAllocations.BinActionType = SAPbobsCOM.BinActionTypeEnum.batToWarehouse;
                transfer.Lines.BinAllocations.BinAbsEntry = toLocation;
                transfer.Lines.BinAllocations.Quantity = quantity;
                transfer.Lines.BinAllocations.Add();

                int returnCode = transfer.Add();

Accepted Solutions (0)

Answers (1)

Answers (1)

edy_simon
Active Contributor
0 Kudos

Hi Yin,

Remove both the 'setcurrentline' lines.

Regards

Edy

Former Member
0 Kudos

Hi Edy,

is it mean for bin allocation assigning , there is no "SetCurrentLine" needed?

transfer.Lines.BinAllocations.SetCurrentLine(0);

i thought it should same as batch/serial number assigning concept. When you have 5 bin location, you need to set current line for each bin location.

edy_simon
Active Contributor
0 Kudos

Hi Yin,

SetCurrentLine is used for moving the focus to a certain row of the childs.

SetCurrentLine(0) means you are asking the focus to move to first row.

When you are adding rows, it does not make sense for you to keep on updating the first row.

This logic applies to all childs of DI API objects, not only bin.

LineItem, Batch are having the same logic.

Regards

Edy

Former Member
0 Kudos

Hi Edy,

Yea, i understand the set current line . This is how i applied previously for the batch/serial assigning

For intBinRowCount = 0 To intTotalRow - 1
                                    oDocument.Lines.SerialNumbers.SetCurrentLine(intBinRowCount)
                                    oDocument.Lines.SerialNumbers.InternalSerialNumber = dviewSerialNo(intBinRowCount)("SerialNo")

                                    If drDocLines("BinEnable") = "Y" Then
                                        oDocument.Lines.BinAllocations.SetCurrentLine(oDocument.Lines.BinAllocations.Count - 1)
                                        oDocument.Lines.BinAllocations.BinAbsEntry = dviewSerialNo(intBinRowCount)("BinAbsEntry")
                                        oDocument.Lines.BinAllocations.BaseLineNumber = oDocument.Lines.Count - 1
                                        oDocument.Lines.BinAllocations.SerialAndBatchNumbersBaseLine = oDocument.Lines.SerialNumbers.Count - 1
                                        oDocument.Lines.BinAllocations.Quantity = 1
                                        oDocument.Lines.BinAllocations.Add()
                                    End If
                                 
                                    oDocument.Lines.SerialNumbers.Add()
                                Next

edy_simon
Active Contributor
0 Kudos

Hi Yin,

Although your code is not wrong :

oDocument.Lines.BinAllocations.SetCurrentLine(oDocument.Lines.BinAllocations.Count - 1)


The above code is actually not needed because you are trying to set the line to the last line.

When you are adding a document, initially, the line focus is already at the last line,

and when you execute the Add() method, the line focus will be automatically moved to the last line.

And in your original sample code, you always use

transfer.Lines.BinAllocations.SetCurrentLine(0);

Which is wrong because you are always setting it to the first line.

Regards

Edy