Skip to Content
0
Jan 22, 2021 at 07:49 PM

Add BP (DI Error: (-5002)

94 Views Last edit Jan 23, 2021 at 02:09 PM 2 rev

I am trying to add new addresses into a BP. If there is an address registered in the BP everything works, but now if it is new addresses return the error -5002 - Error updating BP: [OCRD.State2], 'the linked value' SP 'does not exist'

I test with SAP Business 10 (10.00.140) FP 2011

                    if (oBP.GetByKey(CardCode))
                    {
                        oBP.Addresses.SetCurrentLine(oBP.Addresses.Count - 1);
                        if (!string.IsNullOrEmpty(oBP.Addresses.AddressName))
                        {
                            oBP.Addresses.Add();
                        }
                        UF = json.data.endereco_uf;
                        if (UF.Length > 2)
                        {
                            UF = "";
                        }
                        oBP.Addresses.SetCurrentLine(oBP.Addresses.Count - 1);
                        oBP.Addresses.AddressName = "Novo 1";
                        oBP.Addresses.AddressType = BoAddressType.bo_ShipTo;
                        oBP.Addresses.Street = json.data.endereco_logradouro;
                        oBP.Addresses.Block = json.data.endereco_bairro;
                        oBP.Addresses.ZipCode = json.data.endereco_cep;
                        oBP.Addresses.City = json.data.endereco_municipio;
                        oBP.Addresses.State = UF;
                        oBP.Addresses.County = county;
                        oBP.Addresses.StreetNo = json.data.endereco_numero;
                        oBP.Addresses.BuildingFloorRoom = json.data.endereco_complemento;
                        oBP.Addresses.Add();


                        oBP.Addresses.SetCurrentLine(oBP.Addresses.Count - 1);
                        oBP.Addresses.AddressName = "Novo 2";
                        oBP.Addresses.AddressType = BoAddressType.bo_BillTo;
                        oBP.Addresses.Street = json.data.endereco_logradouro;
                        oBP.Addresses.Block = json.data.endereco_bairro;
                        oBP.Addresses.ZipCode = json.data.endereco_cep;
                        oBP.Addresses.City = json.data.endereco_municipio;
                        oBP.Addresses.State = UF;
                        oBP.Addresses.County = county;
                        oBP.Addresses.StreetNo = json.data.endereco_numero;
                        oBP.Addresses.BuildingFloorRoom = json.data.endereco_complemento;
                        oBP.Addresses.Add();

                        int iRetVal = oBP.Update();
                        if (iRetVal != 0)
                        {
                            Program.oApplication.StatusBar.SetText("Error updating BP: " + Program.oCompany.GetLastErrorDescription(), BoMessageTime.bmt_Short, BoStatusBarMessageType.smt_Error);
                            return false;
                        }