SELECT DISTINCT
hout.name Company_Code,
rt.Transaction_Id Transaction_Id,
rt.PARENT_TRANSACTION_ID Parent_Transaction_Id,
pha.segment1 PO_Number,
(select 'Oracle-'||instance_name from gv$instance where INSTANCE_NUMBER =1)||'-'||hout.name||'-'||PHA.po_header_id||DECODE(XX.SEGMENT1,NULL,NULL,'-'||XX.SEGMENT1) Purchase_Order_Number_Unique_Key,
rsh.comments Delivery_Note,
to_char(rsh.gl_date,'yyyy-MM-dd') GRN_Posting_Date,
PLA.LINE_NUM PO_Line_Number,
(select 'Oracle-'||instance_name from gv$instance where INSTANCE_NUMBER =1)||'-'||hout.name||'-'||PHA.segment1||'-'||PLA.LINE_NUM||'-'||PLA.po_line_id||XX.SEGMENT1||'-'||plla.SHIPMENT_NUM PO_Line_Unique_Key,
rt.CURRENCY_CODE Currency,
rsl.line_num GRN_Line_Number,
(select 'Oracle-'||instance_name from gv$instance where INSTANCE_NUMBER =1) ||'-'||hout.name||'-'||pha.segment1||'-'||rsh.shipment_header_id GRN_Unique_Key,
rsh.receipt_num GRN_Number,
rt.TRANSACTION_TYPE Movement_Type,
rt.QUANTITY*rt.PO_UNIT_PRICE Net_Amount,
rt.QUANTITY Net_Quantity,
rsl.ITEM_DESCRIPTION Product_Service_Desc,
nvl((select ITEM_NUMBER from egp_system_items_b where inventory_item_id= pla.item_id and rownum=1),rsl.ITEM_DESCRIPTION) Product_Service_No,
rt.PO_UNIT_PRICE Rate_unit_price,
(select location_name from hr_locations hl
where hl.location_id = rsl.DELIVER_TO_LOCATION_ID
) Storage_Location,
/*(select LOCATOR_NAME from INV_ITEM_LOCATIONS
where INVENTORY_LOCATION_ID = rsl.locator_id
and SUBINVENTORY_CODE = rsl.TO_SUBINVENTORY
) Storage_Location, */
rt.UOM_CODE,
PLA.QUANTITY-rt.QUANTITY Remaining_Qty,
(PLA.QUANTITY-rt.QUANTITY) * rt.PO_UNIT_PRICE Remaining_Amount,
to_Char(rsL.last_update_date,'yyyy-MM-dd HH:mm:ss') last_update_date,
rsl.attribute1 Temp_1,
rsl.attribute2 Temp_2,
rsl.attribute3 Temp_3,
rsl.attribute4 Temp_4,
rsl.attribute5 Temp_5,
rsl.attribute6 Temp_6,
rsl.attribute7 Temp_7,
rsl.attribute8 Temp_8,
rsl.attribute9 Temp_9,
rsl.attribute10 Temp_10
FROM rcv_shipment_headers rsh,
rcv_shipment_lines rsl,
-- egp_system_items esib,
RCV_TRANSACTIONS rt,
po_headers_All PHA,
po_lines_All PLA,
poz_suppliers ps,
hz_parties hp,
poz_supplier_sites_All_m pssa ,
hr_organization_units_f_tl hout,
XLE_ENTITY_PROFILES xep
,(
select distinct '-'||poh.segment1 segment1, pol.from_header_id, pol.from_line_id
from PO_LINES_ALL POL,po_headers_All POH
where pol.po_header_id=POH.PO_HEADER_ID
) xx,
po_line_locations_All plla
where rsh.shipment_header_id=rsl.shipment_header_id
and rsl.po_header_id=PHA.po_header_id
and rsl.po_line_id=PLA.po_line_id
--and rsl.ITEM_DESCRIPTION = esib.DESCRIPTION
--and rsl.TO_ORGANIZATION_ID = esib.ORGANIZATION_ID
and rsh.shipment_header_id=rt.shipment_header_id
and rsl.shipment_line_id=rt.shipment_line_id
and pha.po_header_id=pla.po_header_id
and pha.PRC_BU_ID=pla.PRC_BU_ID
and rsh.vendor_id= ps.vendor_id
and ps.party_id= hp.party_id
and rsh.vendor_Site_id=pssa.vendor_Site_id
and ps.vendor_id=pssa.vendor_id
and pha.prc_bu_id=hout.organization_id
and PHA.DOCUMENT_STATUS not in ('CANCELED','REJECTED','FINALLY CLOSED','CLOSED','CLOSED FOR INVOICING'
)
and hout.LANGUAGE = USERENV('LANG')
and xep.LEGAL_ENTITY_ID =PHA.soldto_le_id
and hout.name = NVL(:P_BU_NAME,hout.name)
and trunc(rsL.last_update_date) between nvl(:P_FROM_DATE,trunc(rsL.last_update_date)) and nvl(:P_END_DATE,trunc(rsL.last_update_date))
and pha.po_header_id= xx.from_header_id(+)
and PLA.PO_Line_Id=xx.from_line_id(+)
and RT.PO_LINE_LOCATION_ID=plla.LINE_LOCATION_ID(+)
hout.name Company_Code,
rt.Transaction_Id Transaction_Id,
rt.PARENT_TRANSACTION_ID Parent_Transaction_Id,
pha.segment1 PO_Number,
(select 'Oracle-'||instance_name from gv$instance where INSTANCE_NUMBER =1)||'-'||hout.name||'-'||PHA.po_header_id||DECODE(XX.SEGMENT1,NULL,NULL,'-'||XX.SEGMENT1) Purchase_Order_Number_Unique_Key,
rsh.comments Delivery_Note,
to_char(rsh.gl_date,'yyyy-MM-dd') GRN_Posting_Date,
PLA.LINE_NUM PO_Line_Number,
(select 'Oracle-'||instance_name from gv$instance where INSTANCE_NUMBER =1)||'-'||hout.name||'-'||PHA.segment1||'-'||PLA.LINE_NUM||'-'||PLA.po_line_id||XX.SEGMENT1||'-'||plla.SHIPMENT_NUM PO_Line_Unique_Key,
rt.CURRENCY_CODE Currency,
rsl.line_num GRN_Line_Number,
(select 'Oracle-'||instance_name from gv$instance where INSTANCE_NUMBER =1) ||'-'||hout.name||'-'||pha.segment1||'-'||rsh.shipment_header_id GRN_Unique_Key,
rsh.receipt_num GRN_Number,
rt.TRANSACTION_TYPE Movement_Type,
rt.QUANTITY*rt.PO_UNIT_PRICE Net_Amount,
rt.QUANTITY Net_Quantity,
rsl.ITEM_DESCRIPTION Product_Service_Desc,
nvl((select ITEM_NUMBER from egp_system_items_b where inventory_item_id= pla.item_id and rownum=1),rsl.ITEM_DESCRIPTION) Product_Service_No,
rt.PO_UNIT_PRICE Rate_unit_price,
(select location_name from hr_locations hl
where hl.location_id = rsl.DELIVER_TO_LOCATION_ID
) Storage_Location,
/*(select LOCATOR_NAME from INV_ITEM_LOCATIONS
where INVENTORY_LOCATION_ID = rsl.locator_id
and SUBINVENTORY_CODE = rsl.TO_SUBINVENTORY
) Storage_Location, */
rt.UOM_CODE,
PLA.QUANTITY-rt.QUANTITY Remaining_Qty,
(PLA.QUANTITY-rt.QUANTITY) * rt.PO_UNIT_PRICE Remaining_Amount,
to_Char(rsL.last_update_date,'yyyy-MM-dd HH:mm:ss') last_update_date,
rsl.attribute1 Temp_1,
rsl.attribute2 Temp_2,
rsl.attribute3 Temp_3,
rsl.attribute4 Temp_4,
rsl.attribute5 Temp_5,
rsl.attribute6 Temp_6,
rsl.attribute7 Temp_7,
rsl.attribute8 Temp_8,
rsl.attribute9 Temp_9,
rsl.attribute10 Temp_10
FROM rcv_shipment_headers rsh,
rcv_shipment_lines rsl,
-- egp_system_items esib,
RCV_TRANSACTIONS rt,
po_headers_All PHA,
po_lines_All PLA,
poz_suppliers ps,
hz_parties hp,
poz_supplier_sites_All_m pssa ,
hr_organization_units_f_tl hout,
XLE_ENTITY_PROFILES xep
,(
select distinct '-'||poh.segment1 segment1, pol.from_header_id, pol.from_line_id
from PO_LINES_ALL POL,po_headers_All POH
where pol.po_header_id=POH.PO_HEADER_ID
) xx,
po_line_locations_All plla
where rsh.shipment_header_id=rsl.shipment_header_id
and rsl.po_header_id=PHA.po_header_id
and rsl.po_line_id=PLA.po_line_id
--and rsl.ITEM_DESCRIPTION = esib.DESCRIPTION
--and rsl.TO_ORGANIZATION_ID = esib.ORGANIZATION_ID
and rsh.shipment_header_id=rt.shipment_header_id
and rsl.shipment_line_id=rt.shipment_line_id
and pha.po_header_id=pla.po_header_id
and pha.PRC_BU_ID=pla.PRC_BU_ID
and rsh.vendor_id= ps.vendor_id
and ps.party_id= hp.party_id
and rsh.vendor_Site_id=pssa.vendor_Site_id
and ps.vendor_id=pssa.vendor_id
and pha.prc_bu_id=hout.organization_id
and PHA.DOCUMENT_STATUS not in ('CANCELED','REJECTED','FINALLY CLOSED','CLOSED','CLOSED FOR INVOICING'
)
and hout.LANGUAGE = USERENV('LANG')
and xep.LEGAL_ENTITY_ID =PHA.soldto_le_id
and hout.name = NVL(:P_BU_NAME,hout.name)
and trunc(rsL.last_update_date) between nvl(:P_FROM_DATE,trunc(rsL.last_update_date)) and nvl(:P_END_DATE,trunc(rsL.last_update_date))
and pha.po_header_id= xx.from_header_id(+)
and PLA.PO_Line_Id=xx.from_line_id(+)
and RT.PO_LINE_LOCATION_ID=plla.LINE_LOCATION_ID(+)
No comments:
Post a Comment