Skip to Content
author's profile photo Former Member
Former Member

SAP B1 StockTransfer API

Good Day

We are trying to do a Stock transfer through the API. It works perfectly as long as I transfer a single item. How do I transfer Multiple items through the API. I am using the following fields:

FromWarehouse, Lines.ItemCode, Lines.WarehouseCode,Lines.Quantity

I tried using Lines.SetCurrentLine and Lines.Add but none are working, If I add more than one item it will only add last item in the request.



Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • Posted on Dec 12, 2017 at 11:37 AM


    Below sample is working for me:

    SAPbobsCOM.StockTransfer oStockTransfer = (SAPbobsCOM.StockTransfer)oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oStockTransfer);
    oStockTransfer.FromWarehouse = "01";
    oStockTransfer.ToWarehouse = "02";
    oStockTransfer.Lines.ItemCode = "A00001";
    oStockTransfer.Lines.FromWarehouseCode = "01";
    oStockTransfer.Lines.WarehouseCode = "02";
    oStockTransfer.Lines.Quantity = 2;
    oStockTransfer.Lines.ItemCode = "A00002";
    oStockTransfer.Lines.FromWarehouseCode = "01";
    oStockTransfer.Lines.WarehouseCode = "02";
    oStockTransfer.Lines.Quantity = 3;
    int AddStockTransfer = oStockTransfer.Add();
    if (AddStockTransfer != 0)

    Kind regards,


    SAP SME Support

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Dec 15, 2017 at 06:32 AM

    First of all, you have to create a sql view that consists of all the items you want to transfer including its warehouseFrom, warehouseTo and Quantity.
    Below code works for my DI API and I've implemented it on my web based application.
    Hope this will also help you.

    Public Function CreateInvTrans2(ByVal v_tmpbr As IQueryable(Of v_tmpbarcode), ByVal Wrhs As String, ByVal ToBin As String) As String
            Dim oOWTR As SAPbobsCOM.StockTransfer
            Dim tgadapter2 As New TransferGudangAdapter
            Dim angka As String
            Dim linenum As String
            Dim v_obin As v_OBIN
            Dim v_obin2 As v_OBIN
            v_obin = tgadapter2.get_Obin(ToBin).First
                oOWTR = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oStockTransfer)
                Dim SBO As SBOAdapter
                Dim tgadapter As New TransferGudangAdapter
                oOWTR.DocDate = DateTime.Now
                oOWTR.FromWarehouse = WhsFrom
                oOWTR.ToWarehouse = Wrhs
                Dim a = 0
                   For Each WOR1 In v_tmpbr
                        v_obin2 = tgadapter.get_Obin(ToBin).First
                        oOWTR.Lines.ItemCode = WOR1.itemcode
                        oOWTR.Lines.FromWarehouseCode = WhsFrom
                        oOWTR.Lines.WarehouseCode = Wrhs
                        oOWTR.Lines.Quantity = WOR1.Quantity * WOR1.purpackun
                Dim iRetVal = oOWTR.Add
                oOWTR = Nothing
            Catch ex4 As Exception
                Dim msg As String
                msg = "Error : " + ex4.Message() + ""
                Return msg
            End Try
        End Function

    Marini Shen

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.