title: SAP Business One - Add BP (DI Error: (-5002)
body: <p>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'</p>
  <p>I test with SAP Business 10 (10.00.140) FP 2011</p>
  <pre><code>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 &gt; 2)
      {
          UF = &quot;&quot;;
      }
      oBP.Addresses.SetCurrentLine(oBP.Addresses.Count - 1);
      oBP.Addresses.AddressName = &quot;Novo 1&quot;;
      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 = &quot;Novo 2&quot;;
      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(&quot;Error updating BP: &quot; + Program.oCompany.GetLastErrorDescription(), BoMessageTime.bmt_Short, BoStatusBarMessageType.smt_Error);
      return false;
  }
  </code></pre>