on 12-12-2017 8:55 AM - last edited on 02-04-2024 12:07 AM by postmig_api_4
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.
Regards
Ruan
Hi,
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
Try
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
oOWTR.Lines.Add()
Next
Dim iRetVal = oOWTR.Add
System.Runtime.InteropServices.Marshal.ReleaseComObject(oOWTR)
oOWTR = Nothing
GC.Collect()
Catch ex4 As Exception
Dim msg As String
msg = "Error : " + ex4.Message() + ""
Return msg
End Try
End Function
Regards,
Marini Shen
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
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.Add();
oStockTransfer.Lines.ItemCode = "A00002";
oStockTransfer.Lines.FromWarehouseCode = "01";
oStockTransfer.Lines.WarehouseCode = "02";
oStockTransfer.Lines.Quantity = 3;
int AddStockTransfer = oStockTransfer.Add();
if (AddStockTransfer != 0)
{
MessageBox.Show(oCompany.GetLastErrorDescription());
}
Kind regards,
ANKIT CHAUHAN
SAP SME Support
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
110 | |
12 | |
11 | |
6 | |
5 | |
4 | |
4 | |
3 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.