Buen día expertos, estoy elaborando un pequeño código para realizar una copia de una transferencia de stock, es decir, para duplicar una transferencia por medio de código usando DI API y unicamente modificar los almacenes de orígen y destino (no es necesario alterar lotes ni cantidades).
El problema es que me indica que las ubicaciones del almacén original no existen en el nuevo que yo le estoy asignando, y he intentado de varias formas pero no consigo lograrlo. Me aparece el error:
1470000307 - Duplicate bin locations have been removed
Les agrego el fragmento del código en asp.net:
private void RealizarTransferencia()
{
if (oCompany == null || !oCompany.Connected)
this.ConectarCompany();
try
{
//Set up your company object to work with xml import/export.
oCompany.XmlExportType = BoXmlExportTypes.xet_ExportImportMode;
oCompany.XMLAsString = true;
string xmlStockTransfer = string.Empty;
//Load stock transfer
oStTransf = oCompany.GetBusinessObject(BoObjectTypes.oStockTransfer);
if (oStTransf.GetByKey(Int32.Parse(ddlUltimasTransferencias.SelectedValue.ToString())))
{
//Convert strock transfer object in a xml
xmlStockTransfer = oStTransf.GetAsXML();
}
if (!string.IsNullOrEmpty(xmlStockTransfer))
{
//Intialize a new stock transfer through your xml
oStTransf = oCompany.GetBusinessObjectFromXML(xmlStockTransfer, 0);
//Change the fields that you want.
oStTransf.FromWarehouse = "T-MEX";
oStTransf.ToWarehouse = "MEX";
for (int i = 0; i < oStTransf.Lines.Count; i++)
{
oStTransf.Lines.SetCurrentLine(i);
oStTransf.Lines.FromWarehouseCode = "T-MEX";
oStTransf.Lines.WarehouseCode = "MEX";
//oStTransf.Lines.BinAllocations.SetCurrentLine(i);
//oStTransf.Lines.BinAllocations.BinActionType = BinActionTypeEnum.batToWarehouse;
oStTransf.Lines.BinAllocations.BinAbsEntry = 6334;
oStTransf.Lines.BinAllocations.BaseLineNumber = i;
//oStTransf.Lines.BinAllocations.Add();
}
//Add the new transfer.
if (oStTransf.Add() != 0)
{
HttpContext.Current.Response.Write("<script>alert('Error al cargar el documento: " + oCompany.GetLastErrorDescription() + "');</script>");
}
else
{
HttpContext.Current.Response.Write("<script>alert('Transferencia " + oCompany.GetNewObjectKey() + " realizada con éxito');</script>");
}
}
}
catch (Exception ex)
{
HttpContext.Current.Response.Write("<script>alert('Error al crear la transferencia: " + ex.ToString() + "');</script>");
}
}
Alguno habrá tenido un problema similar o sabrá cómo puedo solucionarlo? Agradezco de antemano cualquier apoyo u orientación que puedan brindarme.
Saludos cordiales.