DECLARE
CURSOR missing_mtrh_cur IS
SELECT mtrl.header_id, --move order header id
wdd.organization_id,
enforce_ship_set_and_smc,
wpb.pick_grouping_rule_id,
wpb.name --
FROM wsh_delivery_details wdd,
wsh_shipping_parameters wsp,
mtl_txn_request_lines mtrl,
wsh_picking_batches wpb
WHERE line_id = move_order_line_id
AND source_code = 'OE'
AND wdd.move_order_line_id IS NOT NULL
AND wsp.organization_id = wdd.organization_id
AND wdd.batch_id = wpb.batch_id
AND released_status = 'S'
AND NOT EXISTS
(SELECT 1
FROM mtl_txn_request_headers mtrh
WHERE mtrh.header_id = mtrl.header_id);
l_counter NUMBER := 0;
l_count NUMBER;
BEGIN
FOR missing_mtrh_rec IN missing_mtrh_cur
LOOP
SELECT COUNT (*)
INTO l_count
FROM mtl_txn_request_headers
WHERE header_id = missing_mtrh_rec.header_id;
IF (l_count = 0)
THEN
INSERT INTO mtl_txn_request_headers (created_by,
creation_date,
header_id,
header_status,
last_updated_by,
last_update_date,
last_update_login,
organization_id,
request_number,
move_order_type,
transaction_type_id,
grouping_rule_id)
VALUES (-1,
SYSDATE,
missing_mtrh_rec.header_id,
7,
-1,
SYSDATE,
0,
missing_mtrh_rec.organization_id,
missing_mtrh_rec.name,
3, -- Pick Wave
52, -- Sales Order Pick
missing_mtrh_rec.pick_grouping_rule_id);
END IF;
l_counter := l_counter + 1;
END LOOP;
DBMS_OUTPUT.put_line ('Number of Records Processed : ' || l_counter);
COMMIT;
END;
/
CURSOR missing_mtrh_cur IS
SELECT mtrl.header_id, --move order header id
wdd.organization_id,
enforce_ship_set_and_smc,
wpb.pick_grouping_rule_id,
wpb.name --
FROM wsh_delivery_details wdd,
wsh_shipping_parameters wsp,
mtl_txn_request_lines mtrl,
wsh_picking_batches wpb
WHERE line_id = move_order_line_id
AND source_code = 'OE'
AND wdd.move_order_line_id IS NOT NULL
AND wsp.organization_id = wdd.organization_id
AND wdd.batch_id = wpb.batch_id
AND released_status = 'S'
AND NOT EXISTS
(SELECT 1
FROM mtl_txn_request_headers mtrh
WHERE mtrh.header_id = mtrl.header_id);
l_counter NUMBER := 0;
l_count NUMBER;
BEGIN
FOR missing_mtrh_rec IN missing_mtrh_cur
LOOP
SELECT COUNT (*)
INTO l_count
FROM mtl_txn_request_headers
WHERE header_id = missing_mtrh_rec.header_id;
IF (l_count = 0)
THEN
INSERT INTO mtl_txn_request_headers (created_by,
creation_date,
header_id,
header_status,
last_updated_by,
last_update_date,
last_update_login,
organization_id,
request_number,
move_order_type,
transaction_type_id,
grouping_rule_id)
VALUES (-1,
SYSDATE,
missing_mtrh_rec.header_id,
7,
-1,
SYSDATE,
0,
missing_mtrh_rec.organization_id,
missing_mtrh_rec.name,
3, -- Pick Wave
52, -- Sales Order Pick
missing_mtrh_rec.pick_grouping_rule_id);
END IF;
l_counter := l_counter + 1;
END LOOP;
DBMS_OUTPUT.put_line ('Number of Records Processed : ' || l_counter);
COMMIT;
END;
/
No comments:
Post a Comment