SELECT DISTINCT IOP.organization_code "Site Code",
hauft.name "Site Name",
itrh.request_number "SO NO",
To_char(itrl.creation_date, 'DD-MM-YYYY') "SO Date",
psn.pick_slip_number "ST NO",
To_char(psn.pick_slip_due_date, 'DD-MM-YYYY') "ST DATE",
item_b.item_number
"Ser Ord Item Code",
item_tl.description
"Ser Ord Item Name",
itrl.quantity "Ser Ord Qty",
itrl.quantity_delivered
"Stock Transfer Qty",
Abs(IMT.transaction_quantity) "Item Util Qty",
imt.attribute6 "Proj_code",
iil.description "Engr Name",
itrl.from_subinventory_code
"Source Subinventory",
--IOQD.SUBINVENTORY_CODE LOCATION_CODE,
item_b.primary_uom_code "UOM",
(SELECT
--IMT1.TRANSACTION_QUANTITY
SUM(Abs(IMT1.transaction_quantity))
FROM inv_transaction_types_tl ittt1,
inv_transaction_types_b ittb1,
inv_item_locations iil1,
inv_material_txns IMT1
WHERE ROWNUM = 1
AND itrh.request_number = imt1.attribute7(+)
AND IMT1.inventory_item_id = itrl.inventory_item_id
AND IMT1.organization_id = itrl.organization_id
AND itrl.to_locator_id = iil1.inventory_location_id(+)
AND iil1.inventory_location_id = imt1.locator_id
AND imt1.transaction_type_id =
ittb1.transaction_type_id(+)
AND ittb1.transaction_type_id =
ittt1.transaction_type_id(+)
--and ittt1.TRANSACTION_TYPE_NAME(+) ='Subinventory Transfer'
AND IMT1.subinventory_code = 'Engineers' --
--AND IMT1.TRANSFER_SUBINVENTORY='Engineers'
--AND IMT1.TRANSACTION_QUANTITY>0
)
Stock_Return_From_Eng,
( CASE
WHEN itrl.quantity = itrl.quantity_delivered
AND itrl.quantity = Abs(IMT.transaction_quantity) THEN
'Complete'
ELSE 'Pending'
END ) "SERV ORD Status",
( CASE
WHEN itrl.quantity_delivered < itrl.quantity THEN 'Pending'
WHEN itrl.quantity_delivered IS NULL THEN 'Pending'
ELSE 'Complete'
END ) "Transfer Status",
( CASE
WHEN Abs(IMT.transaction_quantity) < itrl.quantity_delivered
THEN 'Pending'
WHEN IMT.transaction_quantity IS NULL THEN 'Pending'
ELSE 'Complete'
END ) "IU Status",
imt.created_by
"Request Raised By"
FROM inv_pick_slip_lines_v pslv,
inv_pick_slip_numbers psn,
--,HR_locations hrr
inv_txn_request_headers itrh,
inv_txn_request_lines itrl,
inv_org_parameters IOP,
hr_organization_units_f_tl hauft,
--INV_ONHAND_QUANTITIES_DETAIL IOQD,
inv_item_locations iil,
egp_system_items_b item_b,
egp_system_items_tl item_tl,
inv_transaction_types_b ittb,
inv_transaction_types_tl ittt,
inv_material_txns IMT
WHERE itrh.request_number = imt.attribute7(+)
--itrh.request_number=nvl(TO_CHAR(imt.attribute7),itrh.request_number)
AND imt.transaction_type_id = ittb.transaction_type_id(+)
--and ittb.TRANSACTION_TYPE_ID=itrh.TRANSACTION_TYPE_ID
AND ittb.transaction_type_id = ittt.transaction_type_id(+)
--and ittt.TRANSACTION_TYPE_NAME IN('Miscellaneous issue')
AND ittt.transaction_type_name(+) = 'Miscellaneous issue'
AND itrl.header_id = itrh.header_id
AND itrl.inventory_item_id = imt.inventory_item_id(+)
AND itrl.to_locator_id = iil.inventory_location_id(+)
--and imtp.TRANSACTION_SOURCE_ID = itrl.header_id
AND pslv.request_number(+) = itrh.request_number
AND pslv.pick_slip_number = psn.pick_slip_number(+)
AND pslv.trx_source_line_id(+) = itrl.line_id
--and itrh.request_number in ('256001','255006')
AND IOP.organization_id = hauft.organization_id
AND IOP.organization_id = itrh.organization_id
AND item_b.inventory_item_id = itrl.inventory_item_id
AND item_b.organization_id = itrl.organization_id
AND item_tl.inventory_item_id = item_b.inventory_item_id
AND item_tl.organization_id = item_b.organization_id
AND item_tl.LANGUAGE = 'US'
AND hauft.LANGUAGE = 'US'
AND ( itrh.request_number IN ( :SO_NO )
OR 'All' IN( :SO_NO
||'All' ) )
AND ( IOP.organization_code IN ( :Site_Code )
OR 'All' IN( :Site_Code
||'All' ) )
AND ( iil.description IN ( :Engr_name )
OR 'All' IN( :Engr_name
||'All' ) )
AND ( item_b.item_number IN ( :item_number )
OR 'All' IN( :item_number
||'All' ) )
AND ( itrl.from_subinventory_code IN ( :Source_Subinv )
OR 'All' IN( :Source_Subinv
||'All' ) )
AND ( psn.pick_slip_number IN ( :p_pick_slip )
OR Least(:p_pick_slip) IS NULL )
AND ( Trunc(itrl.creation_date) >= ( :p_so_from_date )
OR Least(:p_so_from_date) IS NULL )
AND ( Trunc(itrl.creation_date) <= ( :p_so_to_date )
OR Least(:p_so_to_date) IS NULL )
AND ( Trunc(psn.pick_slip_due_date) >= ( :p_st_from_date )
OR Least(:p_st_from_date) IS NULL )
AND ( Trunc(psn.pick_slip_due_date) <= ( :p_st_to_date )
OR Least(:p_st_to_date) IS NULL )
AND ( Trunc(imt.transaction_date) >= ( :p_iu_from_date )
OR Least(:p_iu_from_date) IS NULL )
AND ( Trunc(imt.transaction_date) <= ( :p_iu_to_date )
OR Least(:p_iu_to_date) IS NULL )
AND ( imt.transaction_id IN ( :p_trx_id )
OR Least(:p_trx_id) IS NULL )
No comments:
Post a Comment