Assuming productcount is required, the following result was found.
to determine which best fits your scenario: Counting total products: // // count total products for availability m_ProductCount = Map(); for each r_StockRecord in Stock_Upload[ID != 0] { if(m_ProductCount.get(v_SKU) == null) {...