SELECT DISTINCT
OOHA.ORDER_NUMBER,
OTTT.NAME "ORDER TYPE",
OOHA.FLOW_STATUS_CODE HEADER_STATUS,
OOLA.CUST_PO_NUMBER,
OOLA.ORDERED_ITEM,
OOLA.UNIT_SELLING_PRICE,
ORDERED_QUANTITY,
QLP.NAME PRICE_LIST,
(SELECT LAST_NAME||', '||FIRST_NAME FROM PER_ALL_PEOPLE_F WHERE PERSON_ID=RSA.PERSON_ID) SALESREP,
OOD.ORGANIZATION_NAME,
HCA.ACCOUNT_NAME "CUSTOMER NAME",
HCA.ACCOUNT_NUMBER CUSTOMER_NUMBER,
HCSUA.LOCATION SHIP_TO_LOCATION,
HL.ADDRESS1||','||HL.ADDRESS2||','||HL.ADDRESS3||','||HL.ADDRESS4||','||HL.CITY||','||HL.STATE||','||HL.POSTAL_CODE||','||HL.COUNTRY SHIP_TO_ADDRESS,
HCSUA1.LOCATION BILL_TO_LOCATION,
HL1.ADDRESS1||','||HL1.ADDRESS2||','||HL1.ADDRESS3||','||HL1.ADDRESS4||','||HL1.CITY||','||HL1.STATE||','||HL1.POSTAL_CODE||','||HL1.COUNTRY BILL_TO_ADDRESS,
--WDD.DELIVERY_DETAIL_ID,
WND.NAME "DELIVERY NUMBER"
,RCTA.TRX_NUMBER "INVOICE NUMBER"
,XTE.TRANSACTION_NUMBER,
APSA.PAYMENT_SCHEDULE_ID,
XLAE.ENTITY_ID,
XLAH.AE_HEADER_ID,
XLAL.GL_SL_LINK_ID,
GIR.JE_BATCH_ID,
L.JE_HEADER_ID,
L.JE_LINE_NUM,
B.NAME BATCH_NAME,
B.DESCRIPTION BATCH_DESCRIPTION,
H.NAME JOURNAL_NAME,
H.STATUS JOURNAL_STATUS,
H.DESCRIPTION JE_DESCRIPTION
FROM OE_ORDER_HEADERS_ALL OOHA,
OE_ORDER_LINES_ALL OOLA,
WSH_DELIVERY_DETAILS WDD,
WSH_DELIVERY_ASSIGNMENTS WDA,
WSH_NEW_DELIVERIES WND,
OE_TRANSACTION_TYPES_TL OTTT,
QP_LIST_HEADERS QLP,
RA_SALESREPS_ALL RSA,
RA_CUSTOMER_TRX_LINES_ALL RCTLA,
RA_CUSTOMER_TRX_ALL RCTA,
HZ_CUST_ACCOUNTS HCA,
HZ_CUST_SITE_USES_ALL HCSUA,
HZ_CUST_ACCT_SITES_ALL HCASA,
HZ_PARTY_SITES HPS,
HZ_LOCATIONS HL,
HZ_CUST_SITE_USES_ALL HCSUA1,
HZ_CUST_ACCT_SITES_ALL HCASA1,
HZ_PARTY_SITES HPS1,
HZ_LOCATIONS HL1,
ORG_ORGANIZATION_DEFINITIONS OOD
--AR_RECEIVABLE_APPLICATIONS_ALL ARAA,
--AR_CASH_RECEIPTS_ALL ACRA
,AR_PAYMENT_SCHEDULES_ALL APSA
,XLA.XLA_TRANSACTION_ENTITIES XTE
,XLA_EVENTS XLAE
,XLA_AE_HEADERS XLAH
,XLA_AE_LINES XLAL
,GL_IMPORT_REFERENCES GIR
,GL_JE_LINES L
,GL_JE_HEADERS H
,GL_JE_BATCHES B
WHERE OOHA.HEADER_ID = OOLA.HEADER_ID
AND OOHA.ORDER_NUMBER = :P_ORDER_NUMBER
AND OOHA.HEADER_ID = WDD.SOURCE_HEADER_ID
AND WDD.DELIVERY_DETAIL_ID = WDA.DELIVERY_DETAIL_ID
AND WDA.DELIVERY_ID = WND.DELIVERY_ID
AND OOHA.PRICE_LIST_ID=QLP.LIST_HEADER_ID
AND OOHA.ORDER_TYPE_ID = OTTT.TRANSACTION_TYPE_ID
AND OOHA.SALESREP_ID=RSA.SALESREP_ID
AND OOHA.SOLD_TO_ORG_ID = HCA.CUST_ACCOUNT_ID
AND HCA.CUST_ACCOUNT_ID=OOHA.SOLD_TO_ORG_ID
AND HCSUA.SITE_USE_ID=OOHA.SHIP_TO_ORG_ID
AND HCSUA.CUST_ACCT_SITE_ID=HCASA.CUST_ACCT_SITE_ID
AND HCSUA.SITE_USE_CODE='SHIP_TO'
AND HCASA.PARTY_SITE_ID=HPS.PARTY_SITE_ID
AND HL.LOCATION_ID=HPS.LOCATION_ID
AND HCSUA1.SITE_USE_ID=OOHA.INVOICE_TO_ORG_ID
AND HCSUA1.CUST_ACCT_SITE_ID=HCASA1.CUST_ACCT_SITE_ID
AND HCSUA1.SITE_USE_CODE='BILL_TO'
AND HCASA1.PARTY_SITE_ID=HPS1.PARTY_SITE_ID
AND HL1.LOCATION_ID=HPS1.LOCATION_ID
AND OOHA.SHIP_FROM_ORG_ID = OOD.ORGANIZATION_ID
AND TO_CHAR (OOHA.ORDER_NUMBER) = RCTLA.INTERFACE_LINE_ATTRIBUTE1
AND TO_CHAR(WND.NAME)=RCTLA.INTERFACE_LINE_ATTRIBUTE3
AND RCTLA.INVENTORY_ITEM_ID=OOLA.INVENTORY_ITEM_ID
AND RCTLA.CUSTOMER_TRX_ID = RCTA.CUSTOMER_TRX_ID
--AND ARAA.APPLIED_CUSTOMER_TRX_ID = RCTA.CUSTOMER_TRX_ID
--AND ACRA.CASH_RECEIPT_ID = ARAA.CASH_RECEIPT_ID
AND RCTA.CUSTOMER_TRX_ID=APSA.CUSTOMER_TRX_ID
AND RCTA.TRX_NUMBER = XTE.TRANSACTION_NUMBER
AND XLAE.ENTITY_ID = XTE.ENTITY_ID
AND XLAE.APPLICATION_ID = XTE.APPLICATION_ID
AND XLAH.EVENT_ID = XLAE.EVENT_ID
AND XLAL.AE_HEADER_ID = XLAH.AE_HEADER_ID
AND GIR.GL_SL_LINK_TABLE = XLAL.GL_SL_LINK_TABLE
AND GIR.GL_SL_LINK_ID = XLAL.GL_SL_LINK_ID
AND L.JE_HEADER_ID = GIR.JE_HEADER_ID
AND L.JE_LINE_NUM = GIR.JE_LINE_NUM
AND H.JE_HEADER_ID = L.JE_HEADER_ID
AND B.JE_BATCH_ID = H.JE_BATCH_ID
AND H.JE_SOURCE = 'Receivables'
AND H.STATUS = 'P';
Thanks
Amar Alam