sql="select quantity - (case when alloc_qty is null then 0 else alloc_qty end) - (case when hold_qty is null then 0 else hold_qty end) , quantity from stock,location,invstat where stock.loc_code = location.loc_code and location.inv_stat = invstat.inv_stat and stock.item_code = ? and stock.site_code = ? and stock.loc_code = ? and stock.lot_no = ? and stock.lot_sl = ? and invstat.available = 'Y'";
sql="select auto_reqc from siteitem where item_code = ? and site_code = ?";
pstmt=conn.prepareStatement(sql);
pstmt.setString(1,itemCode);
pstmt.setString(2,siteCode);
rs=pstmt.executeQuery();
if(rs.next())
{
ls_auto_reqc=rs.getString("auto_reqc");
}
rs.close();rs=null;
pstmt.close();pstmt=null;
if(ls_auto_reqc==null)ls_auto_reqc="N";
sql="select quantity - (case when alloc_qty is null then 0 else alloc_qty end) - (case when hold_qty is null then 0 else hold_qty end) from stock, location, invstat where stock.loc_code = location.loc_code and location.inv_stat = invstat.inv_stat and stock.item_code = ? and stock.site_code = ? and stock.loc_code = ? and stock.lot_no = ? and stock.lot_sl = ? and invstat.available = 'Y'";
if(ls_track_shelf_life.equalsIgnoreCase("Y"))
{
sql=sql+"and (stock.exp_date > ? or stock.exp_date is null) ";