SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO
ALTER PROCEDURE DailyQtyFulfilled
AS
select i.itemnmbr as GP_ItemNumber,
i.itemdesc as GP_ItemDesc,
qtyonhnd as GP_QtyOnHand,
isnull(f.qtyfull,0) as GP_QtyToBeFulfilled,
isnull(f.tot_xtndprce,0) as GP_ExtPrice,
isnull(i.currcost,0) as GP_CurrCost,
isnull(rb_pickdetl.tot_qty_picked,0) as RB_QtyPickedNotShipped,
isnull(rb_binlocat.tot_pcs,0) as RB_QtyOnHand
from iv00102 q (nolock)
inner join iv00101 i (nolock)
on q.itemnmbr = i.itemnmbr
-- Get the fulfilled quantity and extended price from SOP10200
left outer join (select itemnmbr,sum(xtndprce) as tot_xtndprce, sum(qtyfulfi) as qtyfull
from sop10200 (nolock)
where qtyfulfi >0
group by itemnmbr
having sum(qtyfulfi) > 0) f
on q.itemnmbr = f.itemnmbr
-- Get the quantity picked and not shipped from PICKDETL
left outer join (select product, sum(cast(qty_picked as numeric(19,5))) as tot_qty_picked
from myserver2.wmsdata.dbo.pickdetl
-- where complete ='C'
where qty_picked <> '0'
group by product) rb_pickdetl
on q.itemnmbr = cast(rb_pickdetl.product as char(31))
-- Get the quantity on hand from BINLOCAT
left outer join (select product, sum(cast(quantity as int) * cast(packsize as int)) as tot_pcs
from myserver2.wmsdata.dbo.binlocat
group by product) rb_binlocat
on q.itemnmbr = cast(rb_binlocat.product as char(31))
where q.locncode = 'MAPLE'
GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO