cancel
Showing results for 
Search instead for 
Did you mean: 

(Urgent ) Inventory tranfer (DI) - Move Bin allowcation with Batch error

Former Member
0 Kudos

Hi expert!

I have to use SDK to create Inventory transfer (just move Item with Batch code to other  Bins ).

My codes :

.

.....

                     oTransfer.Lines.ItemCode = StrItemCode

                    oTransfer.Lines.Quantity = nQty

                 

                    For i As Integer = 0 To dtItemScan.DefaultView.Count - 1

                        oTransfer.Lines.FromWarehouseCode = FromWhsCode

                        oTransfer.Lines.WarehouseCode = ToWhsCode

                        oTransfer.Lines.BatchNumbers.BatchNumber = dtItemScan.DefaultView(i).Item("BatchCode").ToString

                        oTransfer.Lines.BatchNumbers.Quantity = nQty                     

                        oTransfer.Lines.BatchNumbers.Add()

                        oTransfer.Lines.BinAllocations.BinActionType = SAPbobsCOM.BinActionTypeEnum.batFromWarehouse

                        oTransfer.Lines.BinAllocations.BinAbsEntry = 2 ' CInt(dtItemScan.DefaultView(i).Item("FromBin").ToString)

                        oTransfer.Lines.BinAllocations.Quantity = dtItemScan.DefaultView(i).Item("Quantity")

                       oTransfer.Lines.BinAllocations.SerialAndBatchNumbersBaseLine = i

                        oTransfer.Lines.BinAllocations.Add()

                        oTransfer.Lines.BinAllocations.BinActionType = SAPbobsCOM.BinActionTypeEnum.batToWarehouse

                        oTransfer.Lines.BinAllocations.BinAbsEntry = 4 'CInt(dtItemScan.DefaultView(i).Item("ToBin").ToString)

                        oTransfer.Lines.BinAllocations.Quantity = nQty

                        oTransfer.Lines.BinAllocations.SerialAndBatchNumbersBaseLine = i

                        oTransfer.Lines.BinAllocations.Add()

                    Next

                    oTransfer.Lines.Add()

                'Add the document

                RetVal = oTransfer.Add

Error:

-10 1470000838 - Invalid "敓楲污湁䉤瑡档畎扭牥䉳獡䱥湩e"; specify a valid "敓楲污湁䉤瑡档畎扭牥䉳獡䱥湩e"

I have already added Good Receipt PO successfully . But with above codes use for inventory transfer , I can't not. Help me , please!

Thank you!

Accepted Solutions (1)

Accepted Solutions (1)

maik_delly
Active Contributor
0 Kudos

Hi,

in your code you are trying to create one stocktransferline with different binlocation ( incl. batch ).

You are adding an empty line at the end : in DI Api the first line is already present and you have to add from the 2nd line ( beginning of loop ).

This C# code adds a stocktransfer with 10 lines :

SAPbobsCOM.StockTransfer oTransfer = SBO_Company.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oStockTransfer);

for (int i = 0; i < 10; i++)

{

    int nQty = quantity[0]

    if (i > 0)

        oTransfer.Lines.Add();

    oTransfer.Lines.ItemCode = itemcode[i];

    oTransfer.Lines.Quantity = nQty;

    oTransfer.Lines.FromWarehouseCode = fromwhs[i];

    oTransfer.Lines.WarehouseCode = towhs[i];

    oTransfer.Lines.BatchNumbers.BatchNumber = batch[i];

    oTransfer.Lines.BatchNumbers.Quantity = nQty;

    oTransfer.Lines.BinAllocations.BinActionType = SAPbobsCOM.BinActionTypeEnum.batFromWarehouse;

    oTransfer.Lines.BinAllocations.BinAbsEntry = frombin[i];

    oTransfer.Lines.BinAllocations.Quantity = nQty;

    oTransfer.Lines.BinAllocations.SerialAndBatchNumbersBaseLine = 0;

    oTransfer.Lines.BinAllocations.Add();

    oTransfer.Lines.BinAllocations.BinActionType = SAPbobsCOM.BinActionTypeEnum.batToWarehouse;

    oTransfer.Lines.BinAllocations.BinAbsEntry = tobin[i];

    oTransfer.Lines.BinAllocations.Quantity = nQty;

    oTransfer.Lines.BinAllocations.SerialAndBatchNumbersBaseLine = 0;

            

}

          

if (oTransfer.Add() != 0)

    MessageBox.Show("Error : "+SBO_Company.GetLastErrorDescription());

else

    MessageBox.Show("Transfer added");

Hope it helps,

Maik

Former Member
0 Kudos

THANK YOU!

Answers (0)