Skip to Content
0

Error 1470000519 - Copy Stock Transfer DI API

Dec 04, 2017 at 07:55 PM

44

avatar image

Hi experts,

I am elaborating a code that allows to select a stock transfer to later duplicate it and only change the affected warehouses (from and to), the rest of the information (items, quantities, lots) will stay exactly the same. At the moment I have tried with the following code:

        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.BaseLineNumber = i;
                        //oStTransf.Lines.BinAllocations.SetCurrentLine(i);

                        oStTransf.Lines.BinAllocations.BinActionType = BinActionTypeEnum.batFromWarehouse;
                        oStTransf.Lines.BinAllocations.BinAbsEntry = 6334; //T-MEX
                        oStTransf.Lines.BinAllocations.Quantity = double.Parse(Shared.datosTransferencia.Rows[i][2].ToString());
                        oStTransf.Lines.BinAllocations.SerialAndBatchNumbersBaseLine = 0;
                        oStTransf.Lines.BinAllocations.Add();


                        oStTransf.Lines.BinAllocations.BinActionType = BinActionTypeEnum.batToWarehouse;
                        oStTransf.Lines.BinAllocations.BinAbsEntry = 4254; //MEX
                        oStTransf.Lines.BinAllocations.Quantity = double.Parse(Shared.datosTransferencia.Rows[i][2].ToString());
                        oStTransf.Lines.BinAllocations.SerialAndBatchNumbersBaseLine = 0;
                        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>");
            }
        }

But I get the following error: 1470000519 - "From Bin Locations" must be different from "To Bin Locations"; specify different bin locations in document row 1.

Has anyone had the same problem? "from bin loc." and "to bin loc." are different, I'm assigning a different location.

I thank you in advance for any example or guide that you can give me. Best regards.

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

0 Answers