Skip to Content
0
Jun 22, 2018 at 06:57 AM

ADD WAREHOUSE WITH DI API

251 Views

Hi All,

SAPbobsCOM.Warehouses warehouse = (Warehouses)this.company.GetBusinessObject(BoObjectTypes.oWarehouses);
//fill the fields that you need
warehouse.WarehouseCode = whses[i]; //this field is mandatory
warehouse.WarehouseName = whses[i]; //this field is mandatory
warehouse.Location = 1;

string errorMsg = string.Empty;
int errorCode;
bool isWhs = warehouse.GetByKey(whses[i]);

if (!isWhs)
{
int retval = warehouse.Add();
if (retval != 0)
{
this.company.GetLastError(out errorCode, out errorMsg);
log.Info(string.Format("{0} {1}", errorCode, errorMsg));
}
else
{
log.Info(string.Format("The Warehouse : {0} was added successfully", warehouse.WarehouseCode));
}
}

-5002 Data is not available; modify selection criteria and re-enter