cancel
Showing results for 
Search instead for 
Did you mean: 

SAP Business One 9.3 SDK DI API

0 Kudos

Hi We are trying to update the table ITM 9 again through the di api but the code appears to work but only for some units of measures others it just ignores and doesn't update their prices the prices in the file that need changing that come from the stored proc are all the prices.

You will see my code loops the results table which includes a field new price and old price as test so that it is easy to spot check i set it to a default price.

But i found that only a few of the prices updated when it also was moving onto pricelist 2 I got an access violoation thrown in visual studio.

Has anybody



        public void UpdateUom()
        {
            string Connectionstring = ConfigurationManager.AppSettings["connectionString"];
            try
            {
                using (var conn = new SqlConnection(Connectionstring))
                {
                    List<FeedMixData> _feedmixData = conn.Query<FeedMixData>("FUEL_SPFeedMixUOMResults",
                    commandType: CommandType.StoredProcedure).ToList();


                    SAPbobsCOM.Items oMM = null;
                    oMM = (SAPbobsCOM.Items)company.GetBusinessObject(BoObjectTypes.oItems);
                    foreach (var _item in _feedmixData)


                    {






                        double totalPrice = 123.87;
                        int countLists = oMM.PriceList.Count;


                        Console.Write(string.Format("List Count of PriceLists" + countLists.ToString()));


                        for (int p = 0; p < oMM.PriceList.UoMPrices.Count; p++)
                            {
                           
                                oMM.PriceList.UoMPrices.SetCurrentLine(p);
                                oMM.PriceList.UoMPrices.Delete();
                                oMM.PriceList.UoMPrices.Price = totalPrice;// (double)_item.NewPrice;                                
                                oMM.PriceList.UoMPrices.UoMEntry = _item.UomEntry;
                                oMM.PriceList.UoMPrices.PriceList = _item.PriceList;                                
                                oMM.PriceList.UoMPrices.Add();
                                Console.Write(string.Format("Updating Stock Code {2} price from {0} to {1} FOR PriceList {3}" +Environment.NewLine, _item.Price, totalPrice,_item.ItemCode,_item.PriceList.ToString()));
                                int isUpdate = oMM.Update();
                            }
                           }
                }
            }
            catch (Exception EX)
            {
                Console.Write("Error occoured" + company.GetLastErrorDescription());
            }
        }


Accepted Solutions (0)

Answers (0)