Tuesday, June 10, 2014

Script to identify old orphan move orders

This is script to identify Open move order lines which are not linked to Delivery details , Orphan suggestions in Mtl_material_transactions_temp and  reservations link to Mtl_material_transactions_temp if reservations are not existing.

a) select mmtt.*
from mtl_material_transactions_temp mmtt,
mtl_txn_request_lines mtrl,
mtl_txn_request_headers mtrh
where mmtt.move_order_line_id IS NOT NULL
AND mmtt.move_order_line_id = mtrl.line_id
AND mtrl.line_status = 7
and mtrl.header_id = mtrh.header_id
and mtrh.move_order_type = 3
and not exists (
select 'Y'
from wsh_delivery_details
where move_order_line_id = mtrl.line_id
and released_status = 'S' 

b)  Find allocation records for closed move order
 select mmtt.* 
from mtl_material_transactions_temp mmtt, mtl_txn_request_lines mtrl 
where mmtt.move_order_line_id = mtrl.line_id 
and mtrl.line_status = 5 

c)  Find  allocation records with missing move order
  select mmtt.* 
from mtl_material_transactions_temp mmtt 
where move_order_line_id IS NOT NULL 
and not exists ( 
select mtrl.line_id 
from mtl_txn_request_lines mtrl 
where mtrl.line_id = mmtt.move_order_line_id) 

d)    select mtrl.*
from mtl_txn_request_lines mtrl,
mtl_txn_request_headers mtrh
where mtrl.line_status = 7
and mtrl.header_id = mtrh.header_id
and mtrh.move_order_type = 3
and not exists (
select 'Y'
from wsh_delivery_details
where move_order_line_id = mtrl.line_id
and released_status = 'S'


1 comment: