-- Created on 2011-7-22 by WANG JUAN
DECLARE
-- Local variables here
l_iface_rcv_rec po.rcv_transactions_interface%ROWTYPE;
l_iface_hdr_rec po.rcv_headers_interface%ROWTYPE;
g_receipt_group_id NUMBER;
CURSOR cur_data IS
SELECT ph.po_header_id,
ph.vendor_id,
ph.vendor_site_id,
pl.po_line_id,
rsh.shipment_header_id,
rsl.unit_of_measure,
pd.po_distribution_id,
pd.quantity_ordered,
rt.po_unit_price,
rt.transaction_id,
rt.organization_id,
rsl.ship_to_location_id,
rsl.shipment_line_id,
pd.line_location_id,
msi.inventory_item_id,
msi.description,
mic.category_id,
rt.group_id,
rt.uom_code,
rt.employee_id,
rt.location_id,
rt.inspection_status_code,
rt.currency_conversion_date,
rt.deliver_to_person_id,
rt.deliver_to_location_id,
rt.attribute6,
rt.comments,
rt.routing_header_id,
rt.routing_step_id
FROM rcv_transactions rt,
rcv_shipment_headers rsh,
rcv_shipment_lines rsl,
po_headers_all ph,
po_lines_all pl,
po_distributions_all pd,
mtl_system_items_b msi,
mtl_item_categories mic
WHERE rt.po_header_id = ph.po_header_id
AND rt.po_line_id = pl.po_line_id
AND ph.po_header_id = pl.po_header_id
AND pd.po_header_id = ph.po_header_id
AND pd.po_line_id = pl.po_line_id
AND rt.shipment_header_id = rsh.shipment_header_id
AND rt.shipment_line_id = rsl.shipment_line_id
AND msi.inventory_item_id = pl.item_id
AND msi.organization_id = rt.organization_id
AND msi.inventory_item_id = mic.inventory_item_id
AND msi.organization_id = mic.organization_id
AND mic.category_set_id = 1100000021
AND rt.transaction_id = 1807114;
BEGIN
FOR l_data IN cur_data LOOP
SELECT po.rcv_interface_groups_s.NEXTVAL
INTO g_receipt_group_id
FROM dual;
dbms_output.put_line(g_receipt_group_id);
-- Test statements here
SELECT rcv_transactions_interface_s.NEXTVAL
INTO l_iface_rcv_rec.interface_transaction_id
FROM dual;
l_iface_rcv_rec.last_update_date := SYSDATE;
l_iface_rcv_rec.last_updated_by := 1;
l_iface_rcv_rec.creation_date := SYSDATE;
l_iface_rcv_rec.created_by := 1;
l_iface_rcv_rec.last_update_login := -1;
l_iface_rcv_rec.group_id := g_receipt_group_id;
l_iface_rcv_rec.shipment_header_id := l_data.shipment_header_id;
l_iface_rcv_rec.processing_status_code := 'PENDING';
l_iface_rcv_rec.transaction_status_code := 'PENDING';
l_iface_rcv_rec.processing_mode_code := 'BATCH';
l_iface_rcv_rec.receipt_source_code := 'VENDOR';
l_iface_rcv_rec.vendor_id := l_data.vendor_id;
l_iface_rcv_rec.vendor_site_id := l_data.vendor_site_id;
l_iface_rcv_rec.source_document_code := 'PO';
l_iface_rcv_rec.po_header_id := l_data.po_header_id;
l_iface_rcv_rec.po_line_id := l_data.po_line_id;
l_iface_rcv_rec.po_line_location_id := l_data.line_location_id;
l_iface_rcv_rec.po_release_id := NULL;
l_iface_rcv_rec.transaction_type := 'DELIVER';--'ACCEPT';
l_iface_rcv_rec.auto_transact_code := NULL;
l_iface_rcv_rec.destination_type_code := 'INVENTORY';--'RECEIVING';
l_iface_rcv_rec.shipment_line_id := l_data.shipment_line_id;
l_iface_rcv_rec.parent_transaction_id := l_data.transaction_id;
l_iface_rcv_rec.po_distribution_id := l_data.po_distribution_id;
l_iface_rcv_rec.category_id := 763;--l_data.category_id;
l_iface_rcv_rec.item_id := l_data.inventory_item_id;
l_iface_rcv_rec.transaction_date := SYSDATE;
l_iface_rcv_rec.quantity := 400;
l_iface_rcv_rec.validation_flag := 'Y';
l_iface_rcv_rec.unit_of_measure := l_data.unit_of_measure;
l_iface_rcv_rec.uom_code := l_data.uom_code;--NULL;
l_iface_rcv_rec.po_unit_price := l_data.po_unit_price;
l_iface_rcv_rec.inspection_status_code := 'ACCEPTED';
l_iface_rcv_rec.destination_context := 'INVENTORY';--'RECEIVING';
l_iface_rcv_rec.currency_conversion_date := trunc(SYSDATE);
l_iface_rcv_rec.employee_id := l_data.employee_id;
l_iface_rcv_rec.deliver_to_person_id := l_data.deliver_to_person_id;
l_iface_rcv_rec.deliver_to_location_id := l_data.deliver_to_location_id;
l_iface_rcv_rec.routing_header_id := l_data.routing_header_id;
l_iface_rcv_rec.routing_step_id := l_data.routing_step_id;
l_iface_rcv_rec.to_organization_id := l_data.organization_id;
l_iface_rcv_rec.ship_to_location_id := l_data.ship_to_location_id;
l_iface_rcv_rec.location_id := l_data.location_id;
l_iface_rcv_rec.subinventory := 'LPMGD02'; --入库用
l_iface_rcv_rec.interface_source_code := 'TEST';
INSERT INTO po.rcv_transactions_interface
VALUES l_iface_rcv_rec;
END LOOP;
END;
*注:注释部分为自动检验时所用参数