SELECT
H.ORDER_NUMBER,
PARTY.PARTY_NAME CUSTOMER_NAME,
CUST_ACCT.ACCOUNT_NUMBER CUSTOMER_NUMBER,
TRUNC(H.ORDERED_DATE) ORDERED_DATE,
PL.NAME PRICELIST_NAME,
RSA.NAME SALESREP_NAME,
H.TRANSACTIONAL_CURR_CODE CURRENCY_CODE,
H.FLOW_STATUS_CODE,
SHIP_SU.LOCATION SHIP_TO_LOCATION,
SHIP_LOC.ADDRESS1 SHIP_TO_ADDR1,
DECODE (ship_loc.city, NULL, NULL,ship_loc.city || ', ')||
DECODE (ship_loc.state,NULL, ship_loc.province || ', ', ship_loc.state || ', ')||
DECODE (ship_loc.postal_code, NULL, NULL, ship_loc.postal_code || ', ')||
DECODE (ship_loc.country, NULL, NULL, ship_loc.country)
ship_to_add5,
BILL_SU.LOCATION BILL_TO_LOCATION,
BILL_LOC.ADDRESS1 BILL_TO_ADDR1,
DECODE (bill_loc.city, NULL, NULL,bill_loc.city || ', ')||
DECODE (bill_loc.state,NULL, bill_loc.province || ', ',bill_loc.state || ', ')||
DECODE (bill_loc.postal_code,NULL, NULL,bill_loc.postal_code || ', ')||
DECODE (bill_loc.country, NULL, NULL, bill_loc.country)
BILL_to_addr5,
----------------------------------------------------------------------
L.ORDERED_ITEM,
TRUNC(L.SCHEDULE_ARRIVAL_DATE)SHIPPED_DATE,
L.UNIT_SELLING_PRICE,
L.UNIT_LIST_PRICE,
WHA.ORGANIZATION_CODE WHAREHOUSE,
----------REQUITION DETAILS----------
PRHA.SEGMENT1 REQ_NUMBER ,
TRUNC(PRHA.CREATION_DATE)REQ_CREATION_DATE,
PRHA.TYPE_LOOKUP_CODE REQ_TYPE,
----------PODEATILS---------------
PHA.SEGMENT1 PO_NUMBER,
PHA.CREATION_DATE PO_CREATION_DATE,
AS1.VENDOR_NAME SUPPLIER_NAME,
ASA.VENDOR_SITE_CODE,
PLA.UNIT_PRICE ITEM_PURCHASED_PRICE,
PLA.QUANTITY PURCHASES_QUANTITY,
PAV.AGENT_NAME ITEM_PURCHASED_BY,
-------RECPT-------------------
RSH.RECEIPT_NUM ,
RSH.CREATION_DATE RECIEPT_DATE,
RSL.TO_SUBINVENTORY RECIEVED_LOC
FROM
OE_ORDER_HEADERS_ALL H,
HZ_PARTIES PARTY,
HZ_CUST_ACCOUNTS CUST_ACCT,
QP_LIST_HEADERS_TL PL,
RA_SALESREPS_ALL RSA,
HZ_LOCATIONS SHIP_LOC,
HZ_CUST_SITE_USES_ALL SHIP_SU,
HZ_PARTY_SITES SHIP_PS,
HZ_CUST_ACCT_SITES_ALL SHIP_CAS,
---------------------------
HZ_LOCATIONS BILL_LOC,
HZ_CUST_SITE_USES_ALL BILL_SU,
HZ_PARTY_SITES BILL_PS,
HZ_CUST_ACCT_SITES_ALL BILL_CAS,
---------------------------
OE_ORDER_LINES_ALL L,
MTL_PARAMETERS WHA,
---REQ---------
PO_REQUISITION_HEADERS_ALL PRHA,
OE_DROP_SHIP_SOURCES ODSO,
-------PO----
PO_HEADERS_ALL PHA,
PO_REQUISITION_LINES_ALL PRL,
PO_REQ_DISTRIBUTIONS_ALL PRD,
PO_DISTRIBUTIONS_ALL PD,
AP_SUPPLIERS AS1,
AP_SUPPLIER_SITES_ALL ASA,
PO_LINES_ALL PLA,
PO_AGENTS_V PAV,
---RECPTS-----------
RCV_SHIPMENT_HEADERS RSH,
RCV_SHIPMENT_LINES RSL
WHERE
H.ORDER_NUMBER='66436'
AND H.SOLD_TO_ORG_ID=CUST_ACCT.CUST_ACCOUNT_ID
AND CUST_ACCT.PARTY_ID=PARTY.PARTY_ID
-------------------------------------------
AND H.PRICE_LIST_ID = PL.LIST_HEADER_ID(+)
AND PL.LANGUAGE(+) = USERENV ('LANG')
----------------------------------------
AND H.SALESREP_ID=RSA.SALESREP_ID
---------------------------------
AND H.SHIP_TO_ORG_ID = SHIP_SU.SITE_USE_ID
AND SHIP_SU.CUST_ACCT_SITE_ID = SHIP_CAS.CUST_ACCT_SITE_ID
AND SHIP_CAS.PARTY_SITE_ID = SHIP_PS.PARTY_SITE_ID
AND SHIP_LOC.LOCATION_ID = SHIP_PS.LOCATION_ID
---------------------------------------------
AND H.INVOICE_TO_ORG_ID = BILL_SU.SITE_USE_ID(+)
AND BILL_SU.CUST_ACCT_SITE_ID = BILL_CAS.CUST_ACCT_SITE_ID(+)
AND BILL_CAS.PARTY_SITE_ID = BILL_PS.PARTY_SITE_ID(+)
AND BILL_LOC.LOCATION_ID(+) = BILL_PS.LOCATION_ID
-------------------------------
AND L.HEADER_ID=H.HEADER_ID
---------------------------------------
AND L.ORG_ID=WHA.ORGANIZATION_ID
---------------------------------
AND H.HEADER_ID=ODSO.HEADER_ID
AND PRHA.REQUISITION_HEADER_ID=ODSO.REQUISITION_HEADER_ID
AND ODSO.DESTINATION_ORGANIZATION_ID=PRHA.ORG_ID
--------------------------------------------------
--AND PRHA.PREPARER_ID=PHA.AGENT_ID
AND PHA.TYPE_LOOKUP_CODE='STANDARD'
AND PRHA.ORG_ID=PHA.ORG_ID
AND PRHA.REQUISITION_HEADER_ID = PRL.REQUISITION_HEADER_ID
AND PRL.REQUISITION_LINE_ID = PRD.REQUISITION_LINE_ID
AND PRD.DISTRIBUTION_ID = PD.REQ_DISTRIBUTION_ID(+)
AND PD.PO_HEADER_ID = PHA.PO_HEADER_ID(+)
---------------------------------------------------
AND PHA.VENDOR_ID=AS1.VENDOR_ID
---------------------
AND PHA.VENDOR_SITE_ID=ASA.VENDOR_SITE_ID
----------------------------------------
AND PHA.PO_HEADER_ID=PLA.PO_HEADER_ID
------------------------------------
AND PHA.AGENT_ID=PAV.AGENT_ID
---------------------------------
AND PHA.PO_HEADER_ID=RSL.PO_HEADER_ID
AND RSL.SHIPMENT_HEADER_ID=RSH.SHIPMENT_HEADER_ID
H.ORDER_NUMBER,
PARTY.PARTY_NAME CUSTOMER_NAME,
CUST_ACCT.ACCOUNT_NUMBER CUSTOMER_NUMBER,
TRUNC(H.ORDERED_DATE) ORDERED_DATE,
PL.NAME PRICELIST_NAME,
RSA.NAME SALESREP_NAME,
H.TRANSACTIONAL_CURR_CODE CURRENCY_CODE,
H.FLOW_STATUS_CODE,
SHIP_SU.LOCATION SHIP_TO_LOCATION,
SHIP_LOC.ADDRESS1 SHIP_TO_ADDR1,
DECODE (ship_loc.city, NULL, NULL,ship_loc.city || ', ')||
DECODE (ship_loc.state,NULL, ship_loc.province || ', ', ship_loc.state || ', ')||
DECODE (ship_loc.postal_code, NULL, NULL, ship_loc.postal_code || ', ')||
DECODE (ship_loc.country, NULL, NULL, ship_loc.country)
ship_to_add5,
BILL_SU.LOCATION BILL_TO_LOCATION,
BILL_LOC.ADDRESS1 BILL_TO_ADDR1,
DECODE (bill_loc.city, NULL, NULL,bill_loc.city || ', ')||
DECODE (bill_loc.state,NULL, bill_loc.province || ', ',bill_loc.state || ', ')||
DECODE (bill_loc.postal_code,NULL, NULL,bill_loc.postal_code || ', ')||
DECODE (bill_loc.country, NULL, NULL, bill_loc.country)
BILL_to_addr5,
----------------------------------------------------------------------
L.ORDERED_ITEM,
TRUNC(L.SCHEDULE_ARRIVAL_DATE)SHIPPED_DATE,
L.UNIT_SELLING_PRICE,
L.UNIT_LIST_PRICE,
WHA.ORGANIZATION_CODE WHAREHOUSE,
----------REQUITION DETAILS----------
PRHA.SEGMENT1 REQ_NUMBER ,
TRUNC(PRHA.CREATION_DATE)REQ_CREATION_DATE,
PRHA.TYPE_LOOKUP_CODE REQ_TYPE,
----------PODEATILS---------------
PHA.SEGMENT1 PO_NUMBER,
PHA.CREATION_DATE PO_CREATION_DATE,
AS1.VENDOR_NAME SUPPLIER_NAME,
ASA.VENDOR_SITE_CODE,
PLA.UNIT_PRICE ITEM_PURCHASED_PRICE,
PLA.QUANTITY PURCHASES_QUANTITY,
PAV.AGENT_NAME ITEM_PURCHASED_BY,
-------RECPT-------------------
RSH.RECEIPT_NUM ,
RSH.CREATION_DATE RECIEPT_DATE,
RSL.TO_SUBINVENTORY RECIEVED_LOC
FROM
OE_ORDER_HEADERS_ALL H,
HZ_PARTIES PARTY,
HZ_CUST_ACCOUNTS CUST_ACCT,
QP_LIST_HEADERS_TL PL,
RA_SALESREPS_ALL RSA,
HZ_LOCATIONS SHIP_LOC,
HZ_CUST_SITE_USES_ALL SHIP_SU,
HZ_PARTY_SITES SHIP_PS,
HZ_CUST_ACCT_SITES_ALL SHIP_CAS,
---------------------------
HZ_LOCATIONS BILL_LOC,
HZ_CUST_SITE_USES_ALL BILL_SU,
HZ_PARTY_SITES BILL_PS,
HZ_CUST_ACCT_SITES_ALL BILL_CAS,
---------------------------
OE_ORDER_LINES_ALL L,
MTL_PARAMETERS WHA,
---REQ---------
PO_REQUISITION_HEADERS_ALL PRHA,
OE_DROP_SHIP_SOURCES ODSO,
-------PO----
PO_HEADERS_ALL PHA,
PO_REQUISITION_LINES_ALL PRL,
PO_REQ_DISTRIBUTIONS_ALL PRD,
PO_DISTRIBUTIONS_ALL PD,
AP_SUPPLIERS AS1,
AP_SUPPLIER_SITES_ALL ASA,
PO_LINES_ALL PLA,
PO_AGENTS_V PAV,
---RECPTS-----------
RCV_SHIPMENT_HEADERS RSH,
RCV_SHIPMENT_LINES RSL
WHERE
H.ORDER_NUMBER='66436'
AND H.SOLD_TO_ORG_ID=CUST_ACCT.CUST_ACCOUNT_ID
AND CUST_ACCT.PARTY_ID=PARTY.PARTY_ID
-------------------------------------------
AND H.PRICE_LIST_ID = PL.LIST_HEADER_ID(+)
AND PL.LANGUAGE(+) = USERENV ('LANG')
----------------------------------------
AND H.SALESREP_ID=RSA.SALESREP_ID
---------------------------------
AND H.SHIP_TO_ORG_ID = SHIP_SU.SITE_USE_ID
AND SHIP_SU.CUST_ACCT_SITE_ID = SHIP_CAS.CUST_ACCT_SITE_ID
AND SHIP_CAS.PARTY_SITE_ID = SHIP_PS.PARTY_SITE_ID
AND SHIP_LOC.LOCATION_ID = SHIP_PS.LOCATION_ID
---------------------------------------------
AND H.INVOICE_TO_ORG_ID = BILL_SU.SITE_USE_ID(+)
AND BILL_SU.CUST_ACCT_SITE_ID = BILL_CAS.CUST_ACCT_SITE_ID(+)
AND BILL_CAS.PARTY_SITE_ID = BILL_PS.PARTY_SITE_ID(+)
AND BILL_LOC.LOCATION_ID(+) = BILL_PS.LOCATION_ID
-------------------------------
AND L.HEADER_ID=H.HEADER_ID
---------------------------------------
AND L.ORG_ID=WHA.ORGANIZATION_ID
---------------------------------
AND H.HEADER_ID=ODSO.HEADER_ID
AND PRHA.REQUISITION_HEADER_ID=ODSO.REQUISITION_HEADER_ID
AND ODSO.DESTINATION_ORGANIZATION_ID=PRHA.ORG_ID
--------------------------------------------------
--AND PRHA.PREPARER_ID=PHA.AGENT_ID
AND PHA.TYPE_LOOKUP_CODE='STANDARD'
AND PRHA.ORG_ID=PHA.ORG_ID
AND PRHA.REQUISITION_HEADER_ID = PRL.REQUISITION_HEADER_ID
AND PRL.REQUISITION_LINE_ID = PRD.REQUISITION_LINE_ID
AND PRD.DISTRIBUTION_ID = PD.REQ_DISTRIBUTION_ID(+)
AND PD.PO_HEADER_ID = PHA.PO_HEADER_ID(+)
---------------------------------------------------
AND PHA.VENDOR_ID=AS1.VENDOR_ID
---------------------
AND PHA.VENDOR_SITE_ID=ASA.VENDOR_SITE_ID
----------------------------------------
AND PHA.PO_HEADER_ID=PLA.PO_HEADER_ID
------------------------------------
AND PHA.AGENT_ID=PAV.AGENT_ID
---------------------------------
AND PHA.PO_HEADER_ID=RSL.PO_HEADER_ID
AND RSL.SHIPMENT_HEADER_ID=RSH.SHIPMENT_HEADER_ID
No comments:
Post a Comment