Skip to Content
0
Former Member
Aug 16, 2017 at 03:58 PM

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

974 Views

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";
t.Lines.Add();

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: https://archive.sap.com/discussions/thread/3573190

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

Thank you for your time!