SELECT DISTINCT
hout.name Company_Code,
(select 'Oracle-'||instance_name from gv$instance where INSTANCE_NUMBER =1) ||'-'||hout.name Company_Code_Unique_Key,
pha.segment1 PO_Number,
rsh.shipment_header_id GRN_Id,
rsh.receipt_num GRN_Number,
to_char(rsh.CREATION_DATE,'yyyy-MM-dd') GRN_Date,
to_char(rsh.expected_receipt_date,'yyyy-MM-dd') Expected_Receipt_Date,
to_char(rsh.last_update_date,'yyyy-MM-dd HH:mm:ss') last_update_date,
rsh.attribute1 Temp_1,
rsh.attribute1 Temp_2,
rsh.attribute1 Temp_3,
rsh.attribute1 Temp_4,
rsh.attribute1 Temp_5,
rsh.attribute1 Temp_6,
rsh.attribute1 Temp_7,
rsh.attribute1 Temp_8,
rsh.attribute1 Temp_9,
rsh.attribute1 Temp_10
FROM rcv_shipment_headers rsh,
rcv_shipment_lines rsl,
po_headers_All PHA,
poz_suppliers ps,
hz_parties hp,
poz_supplier_sites_All_m pssa ,
hr_organization_units_f_tl hout,
XLE_ENTITY_PROFILES xep ,
(
select poh.segment1 , pol.from_header_id
from PO_LINES_ALL POL,po_headers_All POH
where pol.po_header_id=POH.PO_HEADER_ID
) xx
where rsh.shipment_header_id=rsl.shipment_header_id
and rsl.po_header_id=PHA.po_header_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 hout.LANGUAGE = USERENV('LANG')
and PHA.DOCUMENT_STATUS not in ('CANCELED','REJECTED','FINALLY CLOSED','CLOSED','CLOSED FOR INVOICING'
)
and PHA.po_header_id= xx.from_header_id(+)
and xep.LEGAL_ENTITY_ID =PHA.soldto_le_id
and hout.name = NVL(:P_BU_NAME,hout.name)
and trunc(rsh.last_update_date) between nvl(:P_FROM_DATE,trunc(rsh.last_update_date)) and nvl(:P_END_DATE,trunc(rsh.last_update_date))
hout.name Company_Code,
(select 'Oracle-'||instance_name from gv$instance where INSTANCE_NUMBER =1) ||'-'||hout.name Company_Code_Unique_Key,
pha.segment1 PO_Number,
rsh.shipment_header_id GRN_Id,
rsh.receipt_num GRN_Number,
to_char(rsh.CREATION_DATE,'yyyy-MM-dd') GRN_Date,
to_char(rsh.expected_receipt_date,'yyyy-MM-dd') Expected_Receipt_Date,
to_char(rsh.last_update_date,'yyyy-MM-dd HH:mm:ss') last_update_date,
rsh.attribute1 Temp_1,
rsh.attribute1 Temp_2,
rsh.attribute1 Temp_3,
rsh.attribute1 Temp_4,
rsh.attribute1 Temp_5,
rsh.attribute1 Temp_6,
rsh.attribute1 Temp_7,
rsh.attribute1 Temp_8,
rsh.attribute1 Temp_9,
rsh.attribute1 Temp_10
FROM rcv_shipment_headers rsh,
rcv_shipment_lines rsl,
po_headers_All PHA,
poz_suppliers ps,
hz_parties hp,
poz_supplier_sites_All_m pssa ,
hr_organization_units_f_tl hout,
XLE_ENTITY_PROFILES xep ,
(
select poh.segment1 , pol.from_header_id
from PO_LINES_ALL POL,po_headers_All POH
where pol.po_header_id=POH.PO_HEADER_ID
) xx
where rsh.shipment_header_id=rsl.shipment_header_id
and rsl.po_header_id=PHA.po_header_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 hout.LANGUAGE = USERENV('LANG')
and PHA.DOCUMENT_STATUS not in ('CANCELED','REJECTED','FINALLY CLOSED','CLOSED','CLOSED FOR INVOICING'
)
and PHA.po_header_id= xx.from_header_id(+)
and xep.LEGAL_ENTITY_ID =PHA.soldto_le_id
and hout.name = NVL(:P_BU_NAME,hout.name)
and trunc(rsh.last_update_date) between nvl(:P_FROM_DATE,trunc(rsh.last_update_date)) and nvl(:P_END_DATE,trunc(rsh.last_update_date))
No comments:
Post a Comment