出站報工 扣庫存

支持 wbs ,按單物料 ,

物料接收纔可使用,

需掃碼上料必須掃碼上料,

無需掃碼上料的物料 帶swr 編號的可以通過掃碼上料變成優先使用

By工序 區分線邊倉口庫存

     

with a as /*查工單指定工段所有bom物料,掃碼上料否 EQ */

(select x.site, x.shop_order, x.component_gbo, x.qty, x.erp_step, r.work_center, x.operation, ow.warehouse, x.back_flush,

x.q_or_e, x.qty * 13 sum_qty, nvl(x.sales_order, ' ') sales_order, nvl(to_number(x.so_line), 0) so_line,

nvl(x.wbs, ' ') wbs, x.erp_control_key_group, it.scan_check, it.error_proofing_sign, so.shop_order_type,

swt.swrline

from bom x, routing r, operation_warehouse ow, item it, shop_order so, swrtable swt

where r.erp_step = x.erp_step

and r.shop_order = x.shop_order

and so.shop_order = x.shop_order

and (ow.work_center(+) = r.work_center and ow.operation(+) = r.operation) /*串工序線邊倉*/

and (it.item(+) = x.component_gbo and it.site(+) = x.site) /*串查 掃碼上料*/

and (swt.site(+) = x.site and swt.shop_order(+) = x.shop_order and swt.item(+) = x.component_gbo) /*串swr*/

and x.shop_order = '222700094510'

and x.back_flush = 'X'

and x.enabled = 1 /*有效物料*/

and x.back_flush = 'X' /*只取反衝物料*/

and x.erp_control_key_group = 1 /*當前工段物料*/

order by x.erp_step, x."SEQUENCE"),

a1 as

(select site, shop_order, component_gbo, /*qty,*/ erp_step, /*work_center,*/ operation, warehouse, /*back_flush,*/

q_or_e, sum_qty, wbs, sales_order, so_line, erp_control_key_group, /*error_proofing_sign,*/

/*shop_order_type,*/

case /*工單類型爲SP04orSP12時,盤裝料(PD)的組件物料走不上料(N)的邏輯*/

when shop_order_type in ('SP04', 'SP12' /*, 'SP01'*/) and error_proofing_sign = 'P' then

0

else

a.scan_check

end scan_check, swrline

from a),

b as /*查詢所有符合條件庫存*/

(select x.site, x.inventory, x.item, x.warehouse, a1.scan_check, bind.resrce, bind.created_date_time bindtime,

x.actual_receive_time, x.qty_on_hand, nvl(x.lot_number, ' ') lot_number, nvl(x.so_num, ' ') so_num,

nvl(to_number(x.so_line_num), 0) so_line_num, nvl(x.wbs_num, ' ') wbs_num, nvl(x.swr_num, ' ') swr_num,

nvl(x.mrb_num, ' ') mrb_num

from inventory x, item_resource_bind bind, a1

where x.inventory_type = '122' /*原材料*/

and x.enabled = 1 /*有效物料*/

and x.qty_on_hand > 0 /*庫存>0*/

and exists (select 1 from a1 where (a1.component_gbo = x.item and a1.warehouse = x.warehouse)) /*指定物料,線邊倉*/

and a1.component_gbo(+) = x.item

and bind.inventory(+) = x.inventory /*匹配掃碼上料*/

order by x.item, x.inventory),

b1 as

(select *

from b

where exists (select 1 from a1 where (a1.wbs = b.wbs_num and a1.sales_order = b.so_num and a1.so_line = b.so_line_num)) /*EQ庫存匹配*/

and ((scan_check = 1 and resrce is not null) or scan_check = 0)) /*匹配掃碼上料*/

select site, inventory, item, warehouse, scan_check, resrce, bindtime, actual_receive_time, qty_on_hand, lot_number,

so_num, so_line_num, wbs_num, swr_num, mrb_num

from b1

bom

庫存

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章