Skip to Content

Stock Transfer through DI API is retrieving Error no. -5002

Aug 16, 2017 at 03:58 PM


avatar image

Hello, experts!

I'm trying to do a simple Stock Transfer between two different warehouses. Code goes like this in C#:

StockTransfer t = SAPB1DIConnector.oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oStockTransfer);
t.DocDate = DateTime.Now;
t.FromWarehouse = "01";
t.ToWarehouse = "02";
t.Lines.ItemCode = "A01";
t.Lines.Quantity = 66;
t.Lines.WarehouseCode = "02";

When I try t.Add() it gives me this error:

ErrorNo=-5002 ErrorDescription=10000515 - Item A01 not found in Warehouse 02

What is weird is that I'm taking this item from Warehouse 01 TO Warehouse 02, not the other way around as the error message implies.

Some facts:

  1. Warehouse 01 has plenty of Item A01;
  2. Warehouse 02 doesn't have Item A01, this Stock Transfer is to give items to it;
  3. I tried using negative Quantity, switching From and To warehouses. Nothing worked.

I searched thoroughly and couldn't find StockTransfer and StockTransferLine mandatory fields. I suspect I'm not filling a mandatory field because of this thread's answer:

I tried finding them on SAP Business One SDK Help Center to no avail. I'm using SAPbobsCOM version if that helps.

Thank you for your time!

10 |10000 characters needed characters left characters exceeded

Hi Gustavo,

Are you able to reproduce this situation in a another database?

I had execute your code in a similar scenario and worked fine.

I suggest you just add the line:


if you will need insert more items.

Kind Regards,

Diego Lother

* Please Login or Register to Answer, Follow or Comment.

1 Answer

Best Answer
Edy Simon Aug 17, 2017 at 05:43 AM

Hi Gustavo,

Under your Item Master data for this Item,
Go to Inventory Tab. In the warehouse list, Is there Whs 02 in the list?



Show 1 Share
10 |10000 characters needed characters left characters exceeded

No, it wasn't!
I feel so silly now.

Thanks a lot, Edy!