oracle 欠料报表,EBS ORACLE工单齐套率的计算程序

PROCEDURE Get_wip_accept_item_date(p_use_id in number,

p_org_id IN NUMBER,

p_start_date IN DATE,

p_end_date IN DATE)

is

cursor accept_cursor(p_org number, p_inventory_item_id number) is

select wro.required_quantity,

wro.quantity_issued,

wro.quantity_per_assembly,

wro.wip_entity_id,

wro.organization_id,

wro.inventory_item_id,

wro.required_quantity - NVL(wro.quantity_issued, 0) quantity,

wdj.description

-- wro.mps_required_quantity quantity --净需求

from wip_discrete_jobs wdj, wip_requirement_operations wro

where wdj.wip_entity_id = wro.wip_entity_id

and wdj.organization_id = wro.organization_id

and wro.inventory_item_id = p_inventory_item_id

and wro.organization_id = nvl(p_org, wro.organization_id)

and wdj.status_type in (1, 3) --已发放,未发放

and wdj.class_code not in ('BLA2', 'BLP2')

and wro.wip_supply_type!=6

and wro.required_quantity > NVL(wro.quantity_issued, 0)

-- and wro.date_required between p_start_date and p_end_date

and wdj.scheduled_start_date between p_start_date and p_end_date --modify by lmh0525

-- and wdj.wip_entity_id=169287

--and wro.inventory_item_id =20360

order by wdj.scheduled_start_date

;

--进检

cursor jinjian_cursor(p_org number,

p_inventory_item_id number,

p_tran_id number) is

SELECT RT.TRANSACTION_DATE,

rt.quantity -

nvl(CUX_INV_ARRIVE_ITEM_DATE_new.get_deliver_qty(rt.transaction_id),0) -

nvl(CUX_INV_ARRIVE_ITEM_DATE_new.get_reject_qty(rt.transaction_id),0) -

nvl(tt.qty,0) quantity,

rt.quantity fyquantity,

nvl(CUX_INV_ARRIVE_ITEM_DATE_new.get_reject_qty(rt.transaction_id),0) reject_qty,

rt.transaction_id

FROM RCV_TRANSACTIONS RT,

po_lines_all pll,

(select object_id, sum(quantity) qty

from WIP.CUX_QUANTITY_STATUS

where request_id = p_tran_id

and status='T6'

and Create_By =p_use_id

group by object_id) tt

WHERE RT.TRANSACTION_TYPE = 'RECEIVE'

and rt.po_line_id = pll.po_line_id

and pll.item_id = p_inventory_item_id

and rt.organization_id = p_org

and rt.transaction_id = tt.object_id(+)

and rt.quantity -

nvl(CUX_INV_ARRIVE_ITEM_DATE_new.get_deliver_qty(rt.transaction_id),0) -

nvl(CUX_INV_ARRIVE_ITEM_DATE_new.get_reject_qty(rt.transaction_id),0) -

nvl(tt.qty, 0) > 0

order by RT.TRANSACTION_DATE;

---在途 ship

cursor shipment_cursor(p_org_id number,

p_item_id number,

p_tran_id number) is

SELECT a.Shipment_Line_Id,

a.EXPECTED_RECEIPT_DATE, --预计到货时间*/

a.QUANTITY_SHIPPED - a.QUANTITY_RECEIVED - nvl(tt.qty,0) quantity

FROM MEG_CUX_PO_SHIPMENT_V a,

(select object_id, sum(quantity) qty

from WIP.CUX_QUANTITY_STATUS

where request_id = p_tran_id

and status='SHIP'

and Create_By =p_use_id

group by object_id) tt

WHERE RECEVIED_FLAG = '1'

and SHIP_TO_ORGANIZATION_ID = p_org_id

and ITEM_ID = p_item_id

and a.STAGE <> 'INTERFACE'

and a.Shipment_Line_Id = tt.object_id(+)

and a.QUANTITY_SHIPPED - a.QUANTITY_RECEIVED - nvl(tt.qty,0) > 0;

--采购

cursor po_cursor(p_org_id number, p_item_id number, p_tran_id number) is

SELECT pll.line_location_id,

pll.need_by_date, --需求日期

pll.promised_date, --承诺日期

pll.creation_date, --下单日期

(case when pll.promised_date is null then 'N'

ELSE 'Y' end ) Trflase,--是否更新承诺日期

decode(pll.closed_code,

'CLOSED FOR RECEIVING',

decode(sign(PLL.QUANTITY - PLL.QUANTITY_CANCELLED -

pll.quantity_received),

1,

pll.quantity_received,

PLL.QUANTITY - PLL.QUANTITY_CANCELLED),

PLL.QUANTITY - PLL.QUANTITY_CANCELLED) -

nvl(rsp.QUANTITY_SHIPPED, 0) - nvl(pll.quantity_received, 0) -

nvl(t3.qty, 0) quantity,

decode(nvl(pll.po_release_id, 0),

0,

pha.segment1,

pha.segment1 || '-' || pra.release_num) PO_NO,

PLA.LINE_NUM,PLL.SHIPMENT_NUM,

pv.VENDOR_NAME,nvl(pv.VENDOR_NAME_ALT, pv.VENDOR_NAME) VENDOR_NAME_ALT

FROM po_line_locations_all PLL,

PO_LINES_ALL PLA,

(SELECT a.PO_LINE_LOCATION_ID,

sum(nvl(QUANTITY_SHIPPED, 0) -

nvl(QUANTITY_RECEIVED, 0)) QUANTITY_SHIPPED

FROM MEG_CUX_PO_SHIPMENT_V a

WHERE a.RECEVIED_FLAG = '1'

group by a.PO_LINE_LOCATION_ID) rsp,

(select object_id, sum(quantity) qty

from WIP.CUX_QUANTITY_STATUS cqs

where cqs.status='PO'

AND request_id = p_tran_id

and Create_By =p_use_id

group by object_id) t3,

po_headers_all pha,

po_releases_all pra,

po_vendors pv

WHERE 1 = 1

AND PLL.PO_HEADER_ID = PLA.PO_HEADER_ID

AND PLL.PO_LINE_ID = PLA.PO_LINE_ID

AND pll.line_location_id = rsp.PO_LINE_LOCATION_ID(+)

and pll.shipment_type <> 'PRICE BREAK'

and nvl(pll.closed_code, 'OPEN') not in

('CLOSED', 'FINALLY CLOSED')

AND pla.item_id = p_item_id

and decode(pll.closed_code,

'CLOSED FOR RECEIVING',

decode(sign(PLL.QUANTITY - PLL.QUANTITY_CANCELLED -

pll.quantity_received),

1,

pll.quantity_received,

PLL.QUANTITY - PLL.QUANTITY_CANCELLED),

PLL.QUANTITY - PLL.QUANTITY_CANCELLED) -

nvl(rsp.QUANTITY_SHIPPED, 0) - nvl(pll.quantity_received, 0) -

nvl(t3.qty,0) > 0

and pll.ship_to_organization_id = p_org_id

and pll.line_location_id = t3.object_id(+)

and pha.po_header_id = pll.po_header_id

and pha.org_id = pll.org_id

and pll.po_release_id = pra.po_release_id(+)

and pll.org_id = pra.org_id(+)

and pha.vendor_id = pv.VENDOR_ID

order by pll.promised_date;

--PR数量

cursor pr_cursor(p_org_id number, p_item_id number, p_tran_id number) is

select prh.requisition_header_id,

prl.quantity - nvl(prl.quantity_cancelled, 0) quantity,

prh.creation_date creation_date,

prh.description --

from po_requisition_headers_all prh,

po_requisition_lines_all prl,

mtl_system_items_b msi,

(select object_id, sum(quantity) qty

from WIP.CUX_QUANTITY_STATUS

where request_id = p_tran_id

AND status='PR'

and Create_By =p_use_id

group by object_id) tt

where prl.item_id = msi.inventory_item_id

and prh.requisition_header_id = prl.requisition_header_id

and prl.destination_organization_id = msi.organization_id

and prl.destination_organization_id=p_org_id

and prl.item_id =p_item_id

and prh.requisition_header_id = tt.object_id(+)

and prl.reqs_in_pool_flag ='Y'

and nvl(prl.cancel_flag, 'N')= 'N'

order by prh.creation_date ;

--获取料号

cursor org_item is

select wro.organization_id, wro.inventory_item_id

from wip_discrete_jobs wdj, wip_requirement_operations wro

where wdj.wip_entity_id = wro.wip_entity_id

and wdj.organization_id = wro.organization_id

and wro.organization_id = nvl(p_org_id, wro.organization_id)

and wdj.status_type in (1, 3)

and wdj.class_code not in ('BLA2', 'BLP2')

and wro.required_quantity > NVL(wro.quantity_issued, 0)

--and wro.date_required between p_start_date and p_end_date

and wdj.scheduled_start_date between p_start_date and p_end_date

and wro.wip_supply_type!=6

-- and wdj.wip_entity_id =172093

--and wro.inventory_item_id =20360

--and wro.inventory_item_id = 16750--直接测试某个料号 1213

--and wdj.wip_entity_id in (158327,168572,168577)

--and wro.inventory_item_id = 77234--直接测试某个料号 1213

group by wro.organization_id,

wro.inventory_item_id

;

--dbms_output.put_line('开始'||to_date(p_start_date,'YYYY-MM-DD'));

x_quantity_recv number; -- 合计进检

--x_quantity_stock number; -- 合计库存

x_quantity_ship number; --合计发运

x_quantity_on_order number; -- 合计在途

x_req_qty number;

-- x_quantity_issued number;

x_req_date date;

x_status varchar2(20);

x_subinventory_code varchar2(10);

stock_qty number := 0;

x_L21_ORGQTY number := 0;

p_tran_id number;

x_quantity number := 0; --不同状态对应的数量

x_sum_lack_quantity number := 0;

p_require_id number := 0;

x_inv_quantity number := 0;--需求数量

-- x_required_quantity number := 0;

x_po_no varchar2(50);

x_LINE_NUM number := 0; --行号

x_SHIPMENT_NUM number := 0; --发运号

x_p_vendor varchar2(50);--供应商

l_po_sumqty number := 0;--po总数量

x_sum_inv_check_qty number := 0;

x_pr_qty number := 0;

l_pr_sumqty number := 0;--PR总数量

x_tflase varchar2(20);

x_ship_qty number := 0;

--x_Shipment_Line_Id number := 0;--发运id

l_ent_pending number := 0;

l_nocheck_pending number := 0;

l_reject_qty number := 0;

l_line_location_id number := 0;

l_other_inv_qty number := 0;

x_other_wip_qty number := 0;

l_min_qty number :=0;

begin

delete from WIP.CUX_WIP_ACCEPT_ITEM_DATE where create_by =p_use_id;

delete from WIP.CUX_QUANTITY_STATUS where create_by =p_use_id ;

commit;

SELECT for_CUX_WIP_ACCEPT_ITEM_SEQ.NEXTVAL into p_require_id from dual; --作为请求的id

for l_c in org_item loop

begin

select SUBSTR(MOV.ORGANIZATION_CODE, 2, 2) ||

DECODE(mc.description,

'原材料',

'01',

'半成品/组件',

'02',

'成品',

'03',

'01')

into x_subinventory_code

from mtl_item_categories mic,

meg_cux_org_v mov,

mtl_categories_b mc

where mic.organization_id = mov.ORGANIZATION_ID

and mic.inventory_item_id = l_c.inventory_item_id

and mic.category_set_id = 1100000041

and mic.category_id = mc.category_id

and mc.structure_id = 50355

and mic.organization_id = l_c.organization_id;

-- dbms_output.put_line('组织:'||l_c.organization_id);

-- dbms_output.put_line('料号:'||l_c.inventory_item_id);

exception

when others then

null;

end;

--库存

/* x_quantity_stock := mg_comm_pub.get_inv_qty(l_c.inventory_item_id,

l_c.organization_id, --只考虑力慧组织

0);

*/

--可用库存

stock_qty := Cux_Inv_Arrive_Item_Date_New.get_inv_prdt1_qty(l_c.organization_id,

l_c.inventory_item_id);

x_inv_quantity :=stock_qty;

/* dbms_output.put_line('料号:'||l_c.inventory_item_id);

dbms_output.put_line('库存:'||stock_qty); */

x_L21_ORGQTY := cux_inv_arrive_item_date_NEW.get_inv_l21_prdt1_qty(l_c.inventory_item_id);

--stock_qty := x_quantity_stock;

--进检

x_quantity_recv := mg_comm_pub.get_po_on_order_inv(p_item_id => l_c.inventory_item_id,

p_org_id => l_c.organization_id,

p_subinventory_code => x_subinventory_code,

p_flag => 2);

-- dbms_output.put_line('进检:'||x_quantity_recv);

-- 发运

--x_sum_inv_check_qty :=stock_qty +x_quantity_recv; --库存+进检

x_quantity_ship := wwinv_pub_pkg.get_po_shipQty(p_item_id => l_c.inventory_item_id,

p_org_id => l_c.organization_id);

x_ship_qty :=x_quantity_ship;

--PO数量

x_quantity_on_order := mg_comm_pub.get_po_on_order_inv(p_item_id => l_c.inventory_item_id,

p_org_id => l_c.organization_id,

p_subinventory_code => x_subinventory_code,

p_flag => 0);

l_po_sumqty :=x_quantity_on_order;

--PR数量

x_pr_qty := cux_inv_arrive_item_date_new.get_pr_qty_by_item(l_c.organization_id,

l_c.inventory_item_id);

l_pr_sumqty :=x_pr_qty;

--进检待入库

l_ent_pending:=cux_inv_arrive_item_date_new.get_t6_noinv_by_item(l_c.organization_id,

l_c.inventory_item_id);

--待检数量

l_nocheck_pending:=cux_inv_arrive_item_date_new.get_re_nocheck_by_item(l_c.organization_id,

l_c.inventory_item_id);

l_reject_qty :=cux_inv_arrive_item_date_new.get_reject_qty_by_item(l_c.organization_id,

l_c.inventory_item_id);

l_other_inv_qty:=cux_inv_arrive_item_date_new.get_inv_other_prdt1_qty(l_c.organization_id,

l_c.inventory_item_id);

x_other_wip_qty:=cux_inv_arrive_item_date_new.get_wip_need_qty(l_c.organization_id,

l_c.inventory_item_id,

p_start_date,

p_end_date) ;

--最小订货量

l_min_qty:=cux_inv_arrive_item_date_new.get_min_order_qty(l_c.organization_id,

l_c.inventory_item_id);

-- end loop;

--x_quantity_stock 库存

for l_b in accept_cursor(l_c.organization_id, l_c.inventory_item_id) loop

-- x_req_qty : =l_b.quantity;

--库存 INV

x_req_qty := l_b.quantity;

if nvl(x_req_qty, 0) > 0 then

if stock_qty > 0 then

x_status := 'INV';

x_req_date := sysdate;

--x_inv_quantity :=stock_qty;

if nvl(x_req_qty, 0) <= stock_qty then

--库存满足需求数量

x_sum_lack_quantity :=stock_qty +x_quantity_recv-x_req_qty;--欠料情况

x_quantity := x_req_qty;

stock_qty := stock_qty - x_req_qty;

x_req_qty := 0;

else

x_sum_lack_quantity :=x_quantity_recv;--欠料情况

x_quantity := stock_qty;

x_req_qty := nvl(x_req_qty, 0) - nvl(stock_qty, 0);

stock_qty := 0;

end if;

CUX_INV_ARRIVE_ITEM_DATE_NEW.insert_ARRIVE_ITEM_DATE_COMMIT(l_c.inventory_item_id,

l_c.organization_id,

l_b.wip_entity_id,

p_require_id,

SYSDATE,

x_inv_quantity,

x_L21_ORGQTY,

l_b.required_quantity,

l_b.quantity_issued,

l_b.quantity,

-- x_req_qty,

x_sum_lack_quantity,

x_req_date,

x_status,

x_quantity,

p_use_id,

NULL,

null,

null,

null,

l_b.description,

l_other_inv_qty ,

x_other_wip_qty,

null,

l_min_qty);

CUX_INV_ARRIVE_ITEM_DATE_NEW.insert_report_status_commit(l_c.inventory_item_id,

l_c.organization_id,

l_b.wip_entity_id,

p_require_id,

x_status,

x_quantity,

x_req_date,

p_require_id,

p_use_id );

end if;

end if;

--进检 T6

if nvl(x_req_qty, 0) > 0 then

-- dbms_output.put_line('需求数量:'||x_req_qty);

if x_quantity_recv > 0 then

for l_jinjian in jinjian_cursor(l_c.organization_id,

l_c.inventory_item_id,

p_require_id) loop

--if x_req_qty < x_quantity_recv then

x_status := 'T6';

x_req_date := l_jinjian.transaction_date +

CUX_INV_ARRIVE_ITEM_DATE_NEW.get_preprocessing_leadtime(l_c.organization_id,

l_c.inventory_item_id,

3);

-- x_inv_quantity :=stock_qty;

-- l_reject_qty :=l_jinjian.reject_qty;

if x_req_qty < l_jinjian.quantity then

x_sum_lack_quantity :=x_sum_lack_quantity-x_req_qty;

-- x_quantity_recv := l_jinjian.quantity - x_req_qty;

x_quantity_recv := x_quantity_recv - x_quantity;

x_quantity := x_req_qty;

x_req_qty := 0; --进检满足需求

else

x_sum_lack_quantity :=x_sum_lack_quantity-l_jinjian.quantity;

x_quantity := l_jinjian.quantity;

-- x_quantity_recv := x_quantity_recv - x_quantity;

x_req_qty := x_req_qty - x_quantity;

x_quantity_recv := 0;

end if;

CUX_INV_ARRIVE_ITEM_DATE_NEW.insert_ARRIVE_ITEM_DATE_COMMIT(l_c.inventory_item_id,

l_c.organization_id,

l_b.wip_entity_id,

p_require_id,

SYSDATE,

x_inv_quantity,

x_L21_ORGQTY,

l_b.required_quantity,

l_b.quantity_issued,

l_b.quantity,

x_sum_lack_quantity,

x_req_date,

x_status,

x_quantity,

p_use_id,

NULL,

l_ent_pending,

l_nocheck_pending,

l_reject_qty,

l_b.description,

l_other_inv_qty,

x_other_wip_qty,

null,

l_min_qty);

--插入记录表

CUX_INV_ARRIVE_ITEM_DATE_NEW.insert_report_status_commit(l_c.inventory_item_id,

l_c.organization_id,

l_b.wip_entity_id,

l_jinjian.transaction_id,

x_status,

x_quantity,

x_req_date,

p_require_id,

p_use_id );

end loop;

end if;

end if;

--发运 SHIP

if nvl(x_req_qty, 0) > 0 then

if x_quantity_ship > 0 then

for l_shipment in shipment_cursor(l_c.organization_id,

l_c.inventory_item_id,

p_require_id) loop

x_status := 'SHIP';

x_req_date := l_shipment.EXPECTED_RECEIPT_DATE +

CUX_INV_ARRIVE_ITEM_DATE_NEW.get_preprocessing_leadtime(l_c.organization_id,

l_c.inventory_item_id,

3);

x_sum_lack_quantity:= x_sum_lack_quantity-x_req_qty;

--x_Shipment_Line_Id :=l_shipment.Shipment_Line_Id;

if nvl(x_req_qty, 0) > 0 then

if x_req_qty < l_shipment.quantity then

x_quantity := x_req_qty;

x_quantity_ship := x_quantity_ship - x_req_qty;

x_req_qty := 0;

else

x_quantity := l_shipment.quantity;

x_req_qty := x_req_qty - x_quantity_ship;

x_quantity_ship := 0;

end if;

CUX_INV_ARRIVE_ITEM_DATE_NEW.insert_ARRIVE_ITEM_DATE_COMMIT(l_c.inventory_item_id,

l_c.organization_id,

l_b.wip_entity_id,

p_require_id,

SYSDATE,

x_inv_quantity,

x_L21_ORGQTY,

l_b.required_quantity,

l_b.quantity_issued,

l_b.quantity,

x_sum_lack_quantity,

x_req_date,

x_status,

x_quantity,

p_use_id,

null,

null,

null,

null,

l_b.description,

l_other_inv_qty,

x_other_wip_qty,

x_ship_qty,

l_min_qty);

CUX_INV_ARRIVE_ITEM_DATE_NEW.insert_report_status_commit(l_c.inventory_item_id,

l_c.organization_id,

l_b.wip_entity_id,

l_shipment.Shipment_Line_Id, --事物的id

x_status,

x_quantity,

x_req_date,

p_require_id,

p_use_id );

end if;

end loop;

end if;

end if;

--在途 PO

if nvl(x_req_qty, 0) > 0 then

if x_quantity_on_order > 0 then

for l_po_qty in po_cursor(l_c.organization_id,

l_c.inventory_item_id,

p_require_id) loop

x_status := 'PO';

--判断采购日期

-- x_sum_lack_quantity :=x_sum_inv_check_qty- nvl(x_req_qty, 0);

x_po_no :=l_po_qty.po_no;

x_LINE_NUM:=l_po_qty.LINE_NUM;

x_SHIPMENT_NUM:=l_po_qty.SHIPMENT_NUM;

x_p_vendor :=l_po_qty.VENDOR_NAME_ALT;

l_line_location_id :=l_po_qty.line_location_id;

if nvl(x_req_qty, 0) > 0 then

if l_po_qty.promised_date is not null then

--承诺日期不为空

x_req_date := l_po_qty.promised_date +

CUX_INV_ARRIVE_ITEM_DATE_NEW.get_preprocessing_leadtime(l_c.organization_id,

l_c.inventory_item_id,

3);

elsif (l_po_qty.promised_date is null and

l_po_qty.need_by_date >=

l_po_qty.creation_date +

CUX_INV_ARRIVE_ITEM_DATE_NEW.get_preprocessing_leadtime(l_c.organization_id,

l_c.inventory_item_id,

4)) then

--承诺日期为空,且PO需求日期>=(PO下单日期+预加工+加工中+后加工)

x_req_date := l_po_qty.need_by_date;

else

x_req_date := l_po_qty.creation_date +

CUX_INV_ARRIVE_ITEM_DATE_NEW.get_preprocessing_leadtime(l_c.organization_id,

l_c.inventory_item_id,

4);

end if;

-- x_sum_lack_quantity:= x_sum_lack_quantity-x_req_qty;

if x_req_qty < l_po_qty.quantity then

x_sum_lack_quantity :=x_sum_lack_quantity- nvl(x_req_qty, 0);

x_quantity := x_req_qty;

x_quantity_on_order := l_po_qty.quantity - x_req_qty;

x_req_qty :=0;

-- x_tflase :=l_po_qty.Trflase;

else

x_sum_lack_quantity :=x_sum_lack_quantity-l_po_qty.quantity;

x_quantity := l_po_qty.quantity;

x_req_qty := x_req_qty - l_po_qty.quantity;

x_quantity_on_order := 0;

-- x_tflase :=l_po_qty.Trflase;

-- x_po_qty_now :=-1;

end if;

CUX_INV_ARRIVE_ITEM_DATE_NEW.insert_po_pr_qty_commit(l_c.inventory_item_id,

l_c.organization_id,

l_b.wip_entity_id,

p_require_id,

SYSDATE,

x_inv_quantity,

x_L21_ORGQTY,

l_b.required_quantity,

l_b.quantity_issued,

l_b.quantity,

x_sum_lack_quantity,

x_req_date,

x_status,

x_quantity,

x_po_no,

x_LINE_NUM ,

x_SHIPMENT_NUM ,

x_p_vendor,

l_po_sumqty ,

p_use_id ,

l_po_qty.Trflase,

l_b.description,

l_line_location_id,

l_other_inv_qty,

x_other_wip_qty ,

l_min_qty );

CUX_INV_ARRIVE_ITEM_DATE_NEW.insert_report_status_commit(l_c.inventory_item_id,

l_c.organization_id,

l_b.wip_entity_id,

l_po_qty.line_location_id, --事物的id

x_status,

x_quantity,

x_req_date,

p_require_id,

p_use_id );

end if;

end loop;

end if;

end if;

--请购 PR

if nvl(x_req_qty, 0) > 0 then

if x_pr_qty > 0 then

x_status := 'PR';

--l_pr_sumqty :=x_pr_qty;

for l_pr_qty in pr_cursor (l_c.organization_id,

l_c.inventory_item_id,

p_require_id) loop

x_req_date:= l_pr_qty.creation_date+CUX_INV_ARRIVE_ITEM_DATE_NEW.get_preprocessing_leadtime(l_c.organization_id,

l_c.inventory_item_id,

4);

if nvl(x_req_qty, 0) > 0 then

if x_req_qty < nvl(l_pr_qty.quantity,0) then

x_sum_lack_quantity:= x_sum_lack_quantity-x_req_qty;

x_quantity := x_req_qty;

x_pr_qty := x_pr_qty - x_req_qty;

x_req_qty :=0;

else

x_sum_lack_quantity:= x_sum_lack_quantity-l_pr_qty.quantity;

x_quantity := l_pr_qty.quantity;

x_quantity_recv := l_pr_qty.quantity - x_req_qty;

x_req_qty :=x_req_qty -l_pr_qty.quantity ;

--x_req_qty := x_req_qty - x_quantity_recv;

x_pr_qty := 0;

end if;

CUX_INV_ARRIVE_ITEM_DATE_NEW.insert_pr_qty_commit(l_c.inventory_item_id,

l_c.organization_id,

l_b.wip_entity_id,

p_require_id,

SYSDATE,

x_inv_quantity,

x_L21_ORGQTY,

l_b.required_quantity,

l_b.quantity_issued,

l_b.quantity,

x_sum_lack_quantity,

x_req_date,

x_status,

x_quantity,

l_pr_sumqty,

p_use_id ,

l_b.description,

l_pr_qty.description ,

l_min_qty );

CUX_INV_ARRIVE_ITEM_DATE_NEW.insert_report_status_commit(l_c.inventory_item_id,

l_c.organization_id,

l_b.wip_entity_id,

l_pr_qty.requisition_header_id, --事物的id

x_status,

x_quantity,

x_req_date,

p_require_id,

p_use_id );

end if;

end loop ;

end if;

end if;

--L/T

if nvl(x_req_qty, 0) > 0 then

x_status := 'L/T';

x_req_date := sysdate +CUX_INV_ARRIVE_ITEM_DATE_NEW.get_preprocessing_leadtime(l_c.organization_id,

l_c.inventory_item_id,

4);

if x_sum_lack_quantity<0 then

x_sum_lack_quantity :=x_sum_lack_quantity-x_req_qty;

else x_sum_lack_quantity :=-x_req_qty;

end if ;

CUX_INV_ARRIVE_ITEM_DATE_NEW.insert_ARRIVE_ITEM_DATE_COMMIT(l_c.inventory_item_id,

l_c.organization_id,

l_b.wip_entity_id,

p_require_id,

SYSDATE,

x_inv_quantity,

x_L21_ORGQTY,

l_b.required_quantity,

l_b.quantity_issued,

l_b.quantity,

x_sum_lack_quantity,

x_req_date,

x_status,

x_req_qty,

p_use_id,

NULL,

null,

null,

null,

l_b.description,

l_other_inv_qty,

x_other_wip_qty,

null,

l_min_qty

);

cux_inv_arrive_item_date_NEW.insert_report_status_commit(l_c.inventory_item_id,

l_c.organization_id,

l_b.wip_entity_id,

p_require_id, --事物的id

x_status,

x_quantity,

x_req_date,

p_require_id,

p_use_id );

end if;

end loop;

end loop;

commit;

end;

--

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值